#Lutece3331. On Duty

On Duty

Description

For a high-load system like Lutece, it is necessary to schedule multiple people on duty to ensure stability. In 3202, Lutece becomes very popular, and there are nn system engineers responsible for its maintenance, numbered from 11 to nn.

There is a duty roster denoted by ai,ja_{i,j}. On the first day, Engineer 11 is on duty, and on the second day, Engineer 22 is on duty. For each day starting from the second day, if Engineer ii is on duty today and Engineer jj was on duty yesterday, then Engineer ai,ja_{i,j} will be on duty tomorrow. The duty roster is pre-planned in such a way that the engineer on duty today will not be on duty tomorrow.

The question is: Who is on duty on the mm-th day?

Input

The first line contains two integers n,m (3n500,1m1018)n,m\ (3\le n\le 500, 1\le m\le 10^{18}), indicating the number of engineers and the day we want to know.

For the next nn lines, each line contains nn integers, representing the duty roster ai,j (0ai,jn)a_{i,j}\ (0 \le a_{i,j} \le n). It is guaranteed that only the numbers on the diagonal are 00, i.e. only ai,i=0 (1in)a_{i,i}=0\ (1\le i\le n).

Output

Output one integer xx, indicating Engineer xx will be on duty on the mm-th day.

Samples

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

Note

For the example:

  1. On the second day, Engineer a2,1=3a_{2,1}=3 will be on duty tomorrow, i.e. the third day, since Engineer 22 is on duty today and Engineer 11 was on duty yesterday.
  2. On the third day, Engineer a3,2=1a_{3,2}=1 will be on duty tomorrow, i.e. the fourth day, since Engineer 33 is on duty today and Engineer 22 was on duty yesterday.

Resources

电子科技大学第十四届 ACM 趣味程序设计竞赛