{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eUp to thirty couples will attend a wedding feast, at which they will be seated on either side of a long table. The bride and groom sit at one end, opposite each other, and the bride wears an elaborate headdress that keeps her from seeing people on the same side as her. It is considered bad luck to have a husband and wife seated on the same side of the table. Additionally, there are several pairs of people conducting adulterous relationships (both different-sex and same-sex relationships are possible), and it is bad luck for the bride to see both members of such a pair. Your job is to arrange people at the table so as to avoid any bad luck.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input consists of a number of test cases, followed by a line containing 0 0. Each test case gives \u003ci\u003en\u003c/i\u003e, 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 \u003ci\u003en\u003c/i\u003e - 1 with the bride and groom being 0w and 0h.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor 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\".\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10 6\r\n3h 7h\r\n5w 3w\r\n7h 6w\r\n8w 3w\r\n7h 3w\r\n2w 5h\r\n0 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1h 2h 3w 4h 5h 6h 7h 8h 9h\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}