shil-and-crazy-operation_28727
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).
n,t=map(int,raw_input().split())
a=[0]+map(int,raw_input().split())
p=[0]+map(int,raw_input().split())
q=[i for i in range(n)]

def app(p,x):
	res=[0]*len(p)
	for i in range(len(p)):
		res[i]=x[p[i]]
	return res	

while t>0:
	if t%2: a=app(p,a)
	p=app(p,p)
	t/=2
print " ".join(map(str,a[1:]))
5 3
1 2 3 4 5
3 4 5 2 1

SAMPLE 100 10000
8128 2748 29043 28282 11092 17066 5611 1933 2794 26806 1433 586 28572 9508 21764 14637 16839 5996 23569 16792 10767 19250 10020 10350 11171 31096 904 23773 13250 27155 11025 15739 17023 2395 21247 31637 4289 1575 8742 18627 22413 3065 21068 704 7304 28021 211 20857 10167 21272 29336 27492 1674 16934 20250 29715 16409 4068 5855 10505 7853 5384 22803 20684 12930 13678 27763 8252 29131 4108 12137 2594 6647 27432 4984 11532 13875 12488 30683 21337 28464 3947 5993 14736 2086 4854 3516 3830 11545 18929 14226 25695 30299 19187 29299 32068 17746 11867 32661 14102 
89 73 25 97 95 51 31 50 22 88 2 59 61 68 53 74 38 57 77 4 54 86 18 70 84 37 6 75 78 67 76 69 65 34 28 9 81 10 13 85 36 12 17 62 60 30 87 56 27 83 1 16 47 98 45 99 20 19 43 55 48 71 21 90 5 72 33 32 26 14 91 35 94 63 8 100 40 42 80 11 44 93 49 24 15 58 92 66 3 29 52 39 79 46 64 7 96 82 23 41 100 1000000
16135 12369 21175 16359 5532 11616 2396 447 20733 25024 31983 10285 16519 14315 9298 27539 9182 30341 23276 27604 17713 398 27912 6942 2240 15323 17271 19207 5531 7367 29309 4060 31660 20006 12267 28213 31479 26234 29832 1741 20513 4970 19637 13457 10799 18543 7249 20727 11665 17873 23003 4753 10335 3026 1238 14818 23522 3624 23410 112 32598 15281 4968 32282 24558 11875 6694 30892 16921 6018 8236 20913 26628 15381 29622 1673 24928 5530 28315 30395 2149 27385 31605 25740 20503 30135 30210 25552 18376 26476 27338 11008 30686 25463 31234 31373 31702 16624 25009 3700 
41 45 69 62 35 6 90 17 93 73 89 8 59 29 78 52 50 20 4 61 47 64 70 26 92 24 23 18 76 67 86 21 34 95 85 10 22 42 55 3 14 71 37 56 5 97 27 36 94 43 39 58 13 88 33 48 32 84 15 46 74 87 77 79 96 66 7 11 16 2 65 25 19 49 98 91 1 44 38 99 60 75 53 80 63 81 82 57 12 51 83 30 31 54 28 9 100 40 72 68
1 4 3 2 5 12137 5855 27492 2086 21247 704 211 15739 20857 29043 586 904 22413 16934 17746 27763 8128 23569 5996 18627 11092 29715 4068 22803 14637 30683 28464 9508 21272 26806 3516 3947 13678 2395 4108 7853 21337 11545 14102 16792 28572 10167 29336 2748 10505 1575 5611 2794 4289 29131 5384 27155 32068 29299 7304 19250 13875 10020 17066 20250 31637 6647 12930 4984 2594 14736 3830 11867 30299 10767 19187 10350 21068 17023 8252 25695 16409 5993 12488 3065 1433 18929 31096 27432 28282 32661 11025 11171 14226 1933 28021 11532 13250 16839 23773 1674 21764 20684 4854 8742 32598 1238 31605 24928 20006 11616 16359 30686 9182 12267 24558 20733 17713 11665 17271 16519 29309 27539 4968 4753 6694 18543 23003 6942 28213 15323 26476 16921 25463 26628 19637 7367 16624 1741 31234 5532 112 30892 27385 27338 15381 31983 2149 6018 31660 28315 2396 10799 30395 30135 30210 23410 4060 20913 29622 12369 11008 9298 7249 32282 3624 16135 30341 31702 10285 11875 23276 8236 10335 29832 18376 20727 20503 25740 5531 3026 27604 27912 3700 13457 398 14315 23522 5530 19207 31479 20513 2240 31373 15281 25552 25024 17873 25009 21175 447 26234 1673 14818 4970