#agc036b. [agc036_b]Do Not Duplicate

[agc036_b]Do Not Duplicate

Problem Statement

We have a sequence of NtimesKN \\times K integers: X=(X0,X1,cdots,XNtimesK1)X=(X_0,X_1,\\cdots,X_{N \\times K-1}). Its elements are represented by another sequence of NN integers: A=(A0,A1,cdots,AN1)A=(A_0,A_1,\\cdots,A_{N-1}). For each pair i,ji, j (0leqileqK1,0leqjleqN10 \\leq i \\leq K-1,\\ 0 \\leq j \\leq N-1), XitimesN+j=AjX_{i \\times N + j}=A_j holds.

Snuke has an integer sequence ss, which is initially empty. For each i=0,1,2,cdots,NtimesK1i=0,1,2,\\cdots,N \\times K-1, in this order, he will perform the following operation:

  • If ss does not contain XiX_i: add XiX_i to the end of ss.
  • If ss does contain XiX_i: repeatedly delete the element at the end of ss until ss no longer contains XiX_i. Note that, in this case, we do not add XiX_i to the end of ss.

Find the elements of ss after Snuke finished the operations.

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • 1leqKleq10121 \\leq K \\leq 10^{12}
  • 1leqAileq2times1051 \\leq A_i \\leq 2 \\times 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK A0A_0 A1A_1 cdots\\cdots AN1A_{N-1}

Output

Print the elements of ss after Snuke finished the operations, in order from beginning to end, with spaces in between.


Sample Input 1

3 2
1 2 3

Sample Output 1

2 3

In this case, X=(1,2,3,1,2,3)X=(1,2,3,1,2,3). We will perform the operations as follows:

  • i=0i=0: ss does not contain 11, so we add 11 to the end of ss, resulting in s=(1)s=(1).
  • i=1i=1: ss does not contain 22, so we add 22 to the end of ss, resulting in s=(1,2)s=(1,2).
  • i=2i=2: ss does not contain 33, so we add 33 to the end of ss, resulting in s=(1,2,3)s=(1,2,3).
  • i=3i=3: ss does contain 11, so we repeatedly delete the element at the end of ss as long as ss contains 11, which causes the following changes to ss: (1,2,3)(1,2)(1)()(1,2,3)→(1,2)→(1)→().
  • i=4i=4: ss does not contain 22, so we add 22 to the end of ss, resulting in s=(2)s=(2).
  • i=5i=5: ss does not contain 33, so we add 33 to the end of ss, resulting in s=(2,3)s=(2,3).

Sample Input 2

5 10
1 2 3 2 3

Sample Output 2

3

Sample Input 3

6 1000000000000
1 1 2 2 3 3

Sample Output 3

ss may be empty in the end.


Sample Input 4

11 97
3 1 4 1 5 9 2 6 5 3 5

Sample Output 4

9 2 6