|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|0.5 초 (추가 시간 없음)||512 MB||1||1||1||100.000%|
The schedule of the day for a programming contest usually follows the same pattern: warmup in the morning, followed by lunch time, some rest time, final adjustments of the competition environment and then the start of the contest.
At rest time some contestants prefer to relax, others prefer to socialize and some have a habit of playing some game of cards. Luciano and his friends enjoy playing a game known as “Jar of Water”. Tired of not being the winner, Luciano wants to write a program that, given the initial cards of all players (don’t ask me how he knows it), determines whether he will win or not. If he is not going to win, he can then make up any excuse and ask not to participate in that round.
The game works as follows:
The card that will be passed from one competitor to the next is selected by the following rule:
Knowing the rules, help Luciano write a program that, given the initial setup of the game, tells which player will be declared the winner of the game.
The first line of input contains two integer numbers N and K (2 ≤ N ≤ 13, 1 ≤ K ≤ N) representing the number of contestants in the game and the contestant who will start the game, respectively. Each of the following N lines contains four characters, representing the initial cards for the i-th contestant (not considering the wildcard).
Your program must output a single line, containing an integer number, representing the contestant who will be declared winner of the game.
2 1 33J3 JJJ3
2 2 A2A2 22AA
4 2 774Q JJQ7 44Q7 4QJJ
3 1 JQAA JJJA QQQA