const main = input => {
  const [[N, _], As] = input.map(e => e.map(Number))
  const K = BigInt(input[0][1])

  const city = (def => (
    def((fn, current, left) => (
      left <= 0
        ? current
        : fn(fn, As[current - 1], left - 1n)
    ),
    fn => fn(fn, As[0], K - 1n))
  ))(((val, cb) => cb(val)))

  return [[city]]
}

const wrapper = data => {
  const input = data.trim().split('\n').map(line => line.split(' '))
  const output = main(input)
  console.log(output.map(line => line.join(' ')).join('\n'))
}

wrapper(require('fs').readFileSync('/dev/stdin', 'utf8'))
