{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eFour regional contests, twelve different teammates… Twenty sixth place is\r\nnot that bad indeed, but World Finals would have been much better. And now the\r\ncareer is over, Team.GOV project is closed. The road back home to\r\nYekaterinburg, graduation, and master\u0027s degree in France are ahead…\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThese thoughts were running around the head of Vadim Kantorov when the dean\u0027s\r\nvoice drew him back to reality:\u003cbr\u003e\r\n“Vadim, whom do you want to share a compartment with?”\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eA compartment on a sleeping car contains four main couchettes and two side\r\ncouchettes. There are exactly 6\u003ci\u003en\u003c/i\u003e people in the Ural SU delegation, that\u0027s why\r\nthe dean bought tickets for \u003ci\u003en\u003c/i\u003e consecutive compartments of a sleeping car.\r\nEvery delegation member said what type of couchette they like more: main or\r\nside.\r\nApart from that, everyone wants to share a compartment with their friends.\r\nThe delegation needs to decide who occupies which compartment\r\nso that all these requirements are satisfied.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains an integer \u003ci\u003en\u003c/i\u003e (1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 1000).\r\nThe second line contains a bit string of length of 6\u003ci\u003en\u003c/i\u003e.\r\n\u003ci\u003ei\u003c/i\u003e-th bit in this string is equal to 1 if the \u003ci\u003ei\u003c/i\u003e-th delegation member wants\r\nto occupy a couchette of main type, and 0 if they want a couchette of side type. \r\nThe next line contains an integer \u003ci\u003em\u003c/i\u003e that is the number of pairs of friends\r\n(0 ≤ \u003ci\u003em\u003c/i\u003e ≤ 15\u003ci\u003en\u003c/i\u003e).\r\nThe next \u003ci\u003em\u003c/i\u003e lines contain all those pairs as integers \u003ci\u003ea\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e and \u003ci\u003eb\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e\r\n(1 ≤ \u003ci\u003ea\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e \u0026lt; \u003ci\u003eb\u003c/i\u003e\u003csub\u003e\u003ci\u003ej\u003c/i\u003e\u003c/sub\u003e ≤ 6\u003ci\u003en\u003c/i\u003e).\r\nAll these pairs are distinct.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput \u003ci\u003en\u003c/i\u003e lines.\r\nEach line should contain a space-separated list of delegation members\r\nwho should occupy a compartment together.\r\nEach pair of friends should occupy the same compartment.\r\nThe order of people in a single list can be arbitrary.\r\nThe order of lists also does not matter.\r\nIf there are multiple solutions, you can output any of them.\r\nIt is guaranteed that at least one solution exists.\u003c/div\u003e\u003c/div\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\u003e2\r\n001111001111\r\n2\r\n1 2\r\n7 8\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 2 3 4 5 6\r\n7 8 9 10 11 12\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}