题目描述
Problem Background
HKE is playing a game with $n$ little friends.
Problem Description
There are $n$ seats numbered from $1$ to $n$, and the little friends are also numbered from $1$ to $n$. Initially, each little friend sits in the corresponding seat. HKE's game can be represented by a permutation $A$ of $n$ elements, denoted as $A(A_1, A_2, \cdots, A_n)$. In one round of the game, for all $1 \leq i \leq n$, the little friend sitting in seat $i$ moves to seat $A_i$.
After $k$ rounds of the game, HKE wants to know which little friend is sitting in each of the seats $1, 2, \cdots, n$.
Input Format
The first line contains two integers $n$ and $k$.
The second line contains a permutation $A_1, A_2, \cdots, A_n$.
Output Format
A single line containing $n$ integers representing the little friends' numbers in seats $1, 2, \cdots, n$ after $k$ rounds.
Sample Input and Output
Sample Input #1
5 5
2 3 1 5 4
Sample Output #1
2 3 1 5 4
Sample Input #2
5 4
2 3 1 5 4
Sample Output #2
3 1 2 4 5
Notes
- For $30\%$ of the test cases, $n \leq 1000$ and $k \leq 1000$;
- For $100\%$ of the test cases, $n \leq 100000$ and $k \leq 2^{31} - 1$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分