1381. Shuffle

单点时限: 2.0 sec

内存限制: 256 MB

Byteasar has a pack of n cards that he likes to shuffle. The positions of cards are numbered from 1 to n. Byteasar has acquired such a skill in shuffling that each time he obtains the same arrangement, i.e. a card from the k-th position (1 <= k <= n) always goes to the same ak-th position. We denote by bk the position of the k-th card (i.e. the card initially placed at the k-th position) after Byteasar repeated shuffling l times.

Write a program which:

reads from the standard input the numbers n and l and the sequence of numbers (bk),

determines the sequence of numbers (ak),

writes that sequence to the standard output.

输入格式

In the first line of the standard input there are two positive integers n and l (1 <= n, l <= 1000000). In the consecutive n lines there are successive elements of the sequence (bk), one per line. In the (k + 1)-st line there is a positive integer bk: the final position of the card from the k-th position, 1 <= bk <= n.

输出格式

Your program should write to the standard output n integers: successive elements of the sequence (ak), one per line. In the k-th line there should be one number ak: the position of the card from the k-th position after a single shuffle. You may assume that for the test data there always exist the desired sequence (ak). If there are many such sequences your program should write one of them (arbitrary).

样例

Input
5 2
1
2
5
3
4
Output
1
2
4
5
3
or:
2
1
4
5
3

0 人解决,1 人已尝试。

0 份提交通过,共有 4 份提交。

9.9 EMB 奖励。

创建: 17 年,3 月前.

修改: 7 年,2 月前.

最后提交: 3 年,12 月前.

来源: POI

题目标签