import java.util.*

fun mul(A: Array<Int>, B: Array<Int>): Array<Int> {
    val C = Array(A.size) { it }

    for (i in A.indices) {
        C[i] = B[A[i]]
    }

    return C
}

fun pow(A: Array<Int>, k: Long): Array<Int> {
    var R = Array(A.size) { it }
    var B = A
    var l = k

    while (l > 0) {
        if (l and 1 != 0L) {
            R = mul(R, B)
        }
        B = mul(B, B)
        l /= 2
    }

    return R
}

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toLong()}
    val A = readLine()!!.split(" ").map{it.toInt()}
    val ts = Array(200010) { TreeSet<Int>() }
    val mp = Array(A.size + 1) { it }

    A.forEachIndexed { index, v -> ts[v].add(index) }

    mp[A.size] = 0
    for (i in A.indices.reversed()) {
        if (i == A.size - 1) {
            mp[i] = ts[A[i]].first() + 1

            continue
        }

        val a = ts[A[i]].higher(i)
        if (a != null) {
            if (a >= mp.size - 1) {
                mp[i] = 0
            } else {
                mp[i] = mp[a + 1]
            }
        } else {
            mp[i] = ts[A[i]].first() + 1
        }
    }

    var B = pow(mp, K - 1)
    if (B[0] == B.size - 1) {
        B = pow(mp, K - 2)
    }

    val S = ArrayDeque<Int>()
    val st = TreeSet<Int>()

    for (i in B.first() % A.size until A.size) {
        if (st.contains(A[i])) {
            while (S.isNotEmpty()) {
                st.remove(S.last)
                if (S.pollLast() == A[i]) {
                    break
                }
            } } else {
            S.addLast(A[i])
            st.add(S.last)
        }
    }

    println(S.joinToString(" "))
}
