import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextLong()

    val a = 2*100000 + 1

    val jumpto = Array<Int>(n, { -1 })
    val now_tail = Array<Int>(a, { -1 })
    val head = Array<Int>(a, { -1 })
    val values = Array<Int>(n, { -1 })

    for (i in 0..n-1) {
        val t = cin.nextInt()
        values[i] = t
        if (now_tail[t] != -1) {
            jumpto[now_tail[t]] = i
        }
        now_tail[t] = i
        if (head[t] == -1) {
            head[t] = i
        }
    }

    for (i in 0..n-1) {
        if (jumpto[i] == -1) {
            jumpto[i] = head[values[i]]
        }
    }

    val round = Array<Int>(n, { -1 })
    val passed = Array<Boolean>(n, { false })

    var now = 0
    var now_round = 0
    while(!passed[now]) {
        passed[now] = true
        round[now] = now_round
        if (now >= jumpto[now]) {
            now_round += 1
        }
        now = jumpto[now] + 1
        if (now == n) {
            now_round += 1
            now = 0
        }
    }
    val cycle = now_round - round[now]
    val first = round[now] + 1
    val last = (k - first) % cycle

    var exceed = last.toInt()
    while(true) {
        if (exceed == 0 && now >= jumpto[now]) {
            break
        }
        if (now >= jumpto[now]) {
            exceed -= 1
        }
        now = jumpto[now] + 1
        if (now == n) {
            exceed -= 1
            now = 0
            if (exceed == -1) {
                break
            }
        }
    }

    val ans: MutableList<Int> = mutableListOf()
    while(n > now && exceed >= 0) {
        if (jumpto[now] > now) {
            now = jumpto[now] + 1
        } else {
            ans.add(values[now])
            now += 1
        }
    }

    for (i in 0..ans.size-1) {
        print(ans[i])
        print(" ")
    }
    println()
}