Thanks. I'd studied the code in detail but not studied the test data so closely.
In this case I'd suggest instead of a simple cin.ignore();, something like cin.ignore(1000, '\n' );, or the more general: std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
This is a very common problem, I think maybe there should be a sticky thread for it, that could simply be referred to, rather than the same question and answer over and over again.