#0006AA

Rearrange

In the Σ-prison there are N prisoners. Σ-lets are good men and women except that some of them are poor and have to pirate music and games from the Internet. Some of them are succesfully evading goverment's attempts at hunting down pirates. Some get caught and are put in prison. Today is the national Σ day, so the prisoners get to visit the amusement park. In order for the prisoners to ride the roller-coaster, the amusement park manager needs to rearrange them so they don't make trouble (e.g. exchange pirated movies with their best friends). However, the rearrangement rule that was written on a dusty old piece of paper in the drawer was too complicated for the manager to understand, so he gave it to you, and your task is to give him the final simple rearrangement rule.
A rearrangement rule for rearranging N prisoners is defined as a permutation a of numbers 1..N, where ai is the position from which a prisoner should be moved to the position i. For example, if a2 equals 6, the sixth prisoner should move to the second position in the new arrangement. The piece of paper has a permutation a written on it, and a positive integer M telling you that you need to apply that rearrangement rule M times.


When prisoners entered the amusement park, their indices (unique numbers from 1 to N) formed an increasing sequence.


InputFrom the first line of standard input, read two integers: N and M (1 <= N <= 1.000.000 and 1 <= M <= 10^18). From the second line, read N integers, the replacement rule a.

OutputTo the standard output write N space separated integers, the final arrangement of prisoners.

Sample input:
6 1
6 4 1 2 5 3

Sample output:
6 4 1 2 5 3

Sample input:
7 2
7 6 5 4 3 2 1

Sample output:
1 2 3 4 5 6 7

Explanation for the first testcase: The rule only needs to be applied once, so the prisoners' final arrangement should look exactly like the used rule.


Explanation for the second testcase: The replacement rule effectively says the prisoners need to reverse their order. Since they should do this twice, they will return back to their original positions.

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.