#P6867. Criticism Chain

    ID: 20074 Type: Default 1000ms 256MiB

Criticism Chain

Criticism Chain

Problem Description

There are \( n \) people engaged in a sequence of criticisms. A given matrix \( A \) defines the progression of the criticisms. The process works as follows:

  1. The first criticism: person \( 1 \) criticizes person \( 2 \).
  2. If in the \( (i-1) \)-th criticism, person \( u \) criticized person \( v \), then in the \( i \)-th criticism, person \( v \) criticizes person \( A_{v,u} \).

Your task is to determine who performs the \( k \)-th criticism (i.e. the person who is doing the criticizing in that step).

inputFormat

The first line contains two integers \( n \) and \( k \), where \( n \) is the number of people and \( k \) is the step number of interest. The following \( n \) lines each contain \( n \) integers, where the element in the \( v \)-th row and \( u \)-th column represents \( A_{v,u} \).

outputFormat

Output a single integer indicating the person who performs the \( k \)-th criticism.

sample

3 5
1 2 3
2 3 1
3 1 2
1