Wedding: Input
Wedding: Input
Input
The input consists of a number of test cases, followed by a line containing 0 0. Each test case gives n,
the number of couples, followed by the number of adulterous pairs, followed by the pairs, in the form
4h 2w (husband from couple 4, wife from couple 2), or 10w 4w, or 3h 1h. Couples are numbered
from 0 to n 1 with the bride and groom being 0w and 0h.
Output
For each case, output a single line containing a list of the people that should be seated on the same
side as the bride. If there are several solutions, any one will do. If there is no solution, output a line
containing bad luck.
Sample Input
10 6
3h 7h
5w 3w
7h 6w
8w 3w
7h 3w
2w 5h
0 0
Sample Output
1h 2h 3w 4h 5h 6h 7h 8h 9h