It is well known that it is not easy to select courses in the college, because there is usually conflict among the time of the courses and students are always willing to choose the best teacher. At the beginning of each term, students who are keen on studying always want to select courses as more as possible. Of course there should be no conflict among the courses their selects.
There are 5 classes every day, and 7 days every week (there are also quite a lot of courses on weekends). There are hundreds of courses in the college, and teaching a course needs one class each week. To give students more convenience, though teaching a course needs only one class, a course will be taught several times by different teachers in a week. For example, a course may be taught both at the 3-rd class on Tuesday by Majors and 4-th class on Wednesday by Andy, you should assume that there is no difference between the two classes (though taught by different teachers), and that students can select any teachers teaching the same class to go. Some students consider that selecting courses is not an easy job for them.
What’s more; our ACM team’s coach Fishhead wants to increase a new elective course taught by him after everyone has already choose their required courses. Avoiding too few students on that course, he request ACMers to change their schedules so that they can take that course. Oh, my God, all ACMers have to obey his request and choose all their courses again. However, some of them cannot take that elective course no matter how to change their schedules, for they have to take the certain required courses. Coach Fishhead is sling, he wants to make sure that all ACMers who don’t take the course have conflict between their required courses and his elective course, or he will kick the guy out of ACM team. Wow, what a tough question. Since Fishhead doesn’t want his brain cells killed, he asks you, the cleverest guy in the ACM team to solve the problem for him. For reciprocation, if you solve the problem nicely, Fishhead promises you to be the captain of the team. Aren’t you excited?

The input contains several cases. For each case, the first line contains an integer n (1 <= n <= 100), the number of required courses taught by different teachers in the college. The following n lines represent n different courses. In each line, the first string is the name of teacher; the second string is the name of course which the teacher taught. We may assume that the teachers’ names are all different. All the teachers’ and courses’ names are less than 15 chars and there are no spaces in the strings. Then comes a pair of integers p (1 <= p <= 7) and q (1 <= q <= 5), which means that the course will be taught at the q-th class on the p-th day of a week. After that, a new line will be inputted, with a pair of integers px (1 <= px <= 7) and qx (1 <= qx <= 5), which means that the Fishhead’s course will be taught at the qx-th class on the px-th day of a week.

For each test case, if the courses have conflict before Fishhead’s course adding them, output “Impossible”. If the courses don’t have conflict before Fishhead’s course adding them, but have conflict after the course adding, output “Conflict”. If the courses have conflict after Fishhead’s course adding them, output “Prefect”.

提交代码