Monad#2859

Monad

2 seconds
64 megabytes
Easy

Monad — the simplest mathematical object you can think of. Suppose there is a finite set , and let there be a map of this finite set into itself. Each point in the finite set maps to another point in this set. This is a monad.

Consider the monad \mathbf{f}: \mathbf{X} \to \mathbf{X}, where \mathbf{X} = \{1, \ldots, n\}. We introduce the notation: \mathbf{f_k(x)} = f(f(\ldots f(x)\ldots)) ( times). Your task is, for given and , to determine \mathbf{f_k(x)}.

Input

The first line contains the number — the size of (1 \le n \le 100000). The second line lists integers; the -th number is (1 \le f(i) \le n). The third line contains (1 \le x \le n) and (1 \le k \le 10^{100000}).

Output

Output a single integer: \mathbf{f_k(x)}.

Examples

Example 1

Loading
Loading