P9943 [HackerEarth] shil and crazy operation
普及
题目描述

Shil likes to perform Crazy Operation on an array A1,A2,...AN.

Given an array A1,A2,...AN and permutation P1,P2, ..,PN, a Crazy Operation consists of two parts:

Perform Operation Bi = Ai for every i in 1..N

Perform Operation Ai = BPi for every i in 1..N. Here P is a permutation from 1 to N.

Shil asks you to print the resulting array A1, A2,...AN after doing Crazy Operation on it , T times.

Input format:
The first line of input consists of two integers N and T. The next line consists of N integers A1, A2,...AN. The next line consists of permutation P1,P2,...PN.

Output format:
Print the resulting A1,A2,...AN after doing Crazy operations on it T times.

Constraints:
1≤N≤10^5
1≤T≤10^18
1≤Ai≤10^9

SAMPLE INPUT
5 3
1 2 3 4 5
3 4 5 2 1

SAMPLE OUTPUT
1 4 3 2 5

Explanation

On doing Crazy Operation 1st time resulting array will be (3,4,5,2,1).
On doing second time , resulting array will be (5,2,1,4,3).
On doing third time, resulting array will be (1,4,3,2,5).

输入格式

见题面

输出格式

见题面

样例输入
5 3 1 2 3 4 5 3 4 5 2 1 SAMPLE
样例输出
1 4 3 2 5