Problem G: Rigging Elections

Elections in your country are performed in a one-on-one elimination style. Each week, two people are chosen from a pool of candidates and the country votes on which one they prefer. The loser is eliminated and the winner is returned to the pool of candidates. This process continues until only one candidate remains.

To make a bad voting system even worse, a single person is charged with the responsibility of choosing the two candidates each week. This person happens to be you! Since you are a very selfish person, you plan on rigging the election so your preferred candidate wins. You have access to polling data from which you can determine who would win in every possible head-to-head matchup. Assuming the data accurately represents what the real outcome would be, is it possible to schedule the candidates so your candidate wins?

Input Format

The first line of each test case contains three integers n, m, and c with 1 ≤ n ≤ 100, 1 ≤ m ≤ 100 and 1 ≤ c ≤ n. Here, n indicates the total number of candidates in the initial pool, m is the number of voters and c is the number of your preferred candidate. This is followed by m lines, each containing a permutation of the numbers 1 through n. The i'th line should be interpreted as a ranking of the n candidates by voter i. If two candidates are pitted against each other in an election, then voter i will vote for whoever appears first in their list. You may also assume m is always odd. The last line of input contains three zeros and should not be processed.

Output Format

There is a single line of output for each test case with either the message yes or no indicating if it is possible for you to rig the elections so your preferred candidate c wins.

Sample Input

3 3 1
1 2 3
2 3 1
3 1 2
3 3 1
1 2 3
2 3 1
3 2 1
0 0 0

Sample Output

yes
no

Zac Friggstad