The following languages are only available languages for the problems from the contest

Surprise Language Round #8:

- Kotlin 1.2

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

H. Exchange of Books

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard output*n* pupils, who love to read books, study at school. It is known that each student has exactly one best friend, and each pupil is the best friend of exactly one other pupil. Each of the pupils has exactly one interesting book.

The pupils decided to share books with each other. Every day, all pupils give their own books to their best friends. Thus, every day each of the pupils has exactly one book.

Your task is to use the list of the best friends and determine the exchange of books among pupils after *k* days. For simplicity, all students are numbered from 1 to *n* in all tests.

Input

The first line contains two integers *n* and *k* (2 ≤ *n* ≤ 100000, 1 ≤ *k* ≤ 10^{16}) — the number of pupils and days during which they will exchange books.

The second line contains *n* different integers *a*_{i} (1 ≤ *a*_{i} ≤ *n*), where *a*_{i} is equal to the number of the pupil who has the best friend with the number *i*.

It is guaranteed that no pupil is the best friend of himself.

Output

In a single line print *n* different integers, where *i*-th integer should be equal to the number of the pupil who will have the book, which the pupil with the number *i* had in the beginning, after *k* days.

Examples

Input

4 1

2 4 1 3

Output

3 1 4 2

Input

5 5

3 4 5 2 1

Output

3 4 5 2 1

Input

6 18

2 3 5 1 6 4

Output

1 2 3 4 5 6

Note

The explanation to the first test.

There are 4 pupils and 1 day. The list of the best friends equals to {2, 4, 1, 3}. It means that:

- the pupil with the number 3 — is the best friend of pupil with the number 1,
- the pupil with the number 1 — is the best friend of pupil with the number 2,
- the pupil with the number 4 — is the best friend of pupil with the number 3,
- the pupil with the number 2 — is the best friend of pupil with the number 4.

After the first day the exchange of books will be {3, 1, 4, 2}.

- the pupil with the number 3 will have the book, which the pupil with the number 1 had in the beginning,
- the pupil with the number 1 will have the book, which the pupil with the number 2 had in the beginning,
- the pupil with the number 4 will have the book, which the pupil with the number 3 had in the beginning
- the pupil with the number 2 will have the book, which the pupil with the number 4 had in the beginning.

Thus, the answer is 3 1 4 2.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/25/2018 07:18:19 (d3).

Desktop version, switch to mobile version.

User lists

Name |
---|