Permutation Magic

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

There are sequences A=(a_1,,a_N)A = (a\_1, \dots , a\_N) and B=(b_1,,b_N)B = (b\_1, \dots , b\_N) with the same length NN. a_ia\_i denotes the ii-th element of AA, and its value is an integer between 11 and MM, and the same is true for b_jb\_j, which is the jj-th element of the sequence BB.

You can do a magic trick to the sequence AA only once: you can prepare a permutation P=(p_1,,p_M)P = (p\_1, \dots , p\_M)of integers from 11 through MM, and can change the sequence AA to AA' by using PP as follows: a_i=p_a_ia'\_i = p\_{a\_i} (1iN1 \le i \le N).

You want to make the distance between the sequence AA' and another sequence BB closer by changing AA to AA' through a magic trick. The "distance" between two sequences is defined as Hamming distance. The Hamming distance between two equal-length sequences is the number of positions at which the corresponding values are different.

Among all possible AA', you have to find a sequence which satisfies all of the following conditions.

  • No other possible sequences as AA' have a smaller distance to BB than the distance between this sequence and BB.
  • It is the lexicographically smallest sequence among possible sequences which has the same distance between BB.

Here, a sequence X=(x_1,x_2,,x_N)X = (x\_1, x\_2, \dots , x\_N) is "lexicographically smaller" than another same length sequence Y=(y_1,y_2,,y_N)Y = (y\_1, y\_2, \dots , y\_N) if and only if the following condition holds: there exists an index ii (1iN1 \le i \le N), such that x_j=y_jx\_j = y\_j for all indices jj (1j<i1 \le j < i), and x_i<y_ix\_i < y\_i.

입력

The input consists of a single test case of the following format.

NN MM

a_1a\_1 \dots a_Na\_N

b_1b\_1 \dots b_Nb\_N

The first line consists two integers NN (1N100,0001 \le N \le 100\\,000) and MM (1M601 \le M \le 60), which represent that the length of sequences are NN, and each sequence has NN values between 11 and MM.

The second line consists of NN integers. The ii-th integer is denoted a_ia\_i (1a_iM1 \le a\_i \le M).

The third line consists of NN integers. The -th integer is denoted b_ib\_i (1b_iM1 \le b\_i \le M).

출력

Print NN integers, with spaces in between. The ii-th integer should be the ii-th element of a sequence which satisfies all conditions in the problem statement. Each element of a sequence should be printed as an integer.