#SDNU1230. Honest Village and Lie Village
Honest Village and Lie Village
Description
The Honest Village and The Lie Village’s story you should have heard of.You want to go to a village, the village is the honest village, all the people there are only to tell the truth, now in the way to go, encountered a fork in the road, the road to your destination honest village, and another road leads to another a village called lie village, where people are just lying. Now two men stood at the crossroads where (one of them come from honest village, another is from lie village,), you can ask them two honest village where the village road is determined to be honest, what would you ask them, how to distinguish the two of them who is from the honest village and who is from the lie village?
The method is just pointing to a village to ask two people: "Where are you from?" if that is honest village, two elderly people will say “yes”; if the answer is "no" means that is the lie village. This way can know which is the honest village.
Now change the question, there is a group of people in front of lmh, they are from honest village or lie village, and they know each other from where. can only ask someone from where (for example, two people, you can ask , where is from, if from honest village, then return to , or return to ). and can be the same person. Now according to query to judge all the people come from which village, if you can, export all from honest village, otherwise output “”.
Format
Input
The first line has three non-negative integers , , and . is the number of questions you asked. and are the populations of the honest village and lie village. Each of the following lines has two integers , and . and are the identification numbers of inhabitants, each of which is between and .
Output
For each data set, if it includes sufficient information to classify all people, print the identification numbers of all people from honest village in ascending order, one in a line. Otherwise, , if a given data set does not include sufficient information to identify all people, print in a line.
Samples
2 2 1
1 2 1
2 3 0
3 2 1
1 1 1
2 2 1
3 3 1
1
2
no