#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

// binary search result
struct BSR {
    bool found; // 条件を満たす範囲が見つかったか。falseの場合、begin,endは意味を持たない。
    int128_t begin; // [begin, end]で条件が成り立つ。
    int128_t end;
    BSR(bool found_in, int128_t begin_in, int128_t end_in) { found = found_in; begin = begin_in; end = end_in; }
    //BSR(bool found_in, int128_t begin_in, int128_t end_in) : found(found_in), begin(begin_in), end(end_in) {}
};

//template<class Fn> BSR binary_search(int128_t L, int128_t R, Fn func) {
BSR binary_search(int128_t L, int128_t R, std::function<bool(int128_t)> func) {
    const bool res_L = func(L);
    const bool res_R = func(R);
    if (res_L && res_R) {
        return BSR(true, L, R);
    } else if (!res_L && !res_R) {
        return BSR(false, 0, 0);
    } else {
        int128_t lb = L;
        int128_t ub = R;
        while (lb + 1 < ub) {
            int128_t mid = (lb + ub) / 2;
            if (res_L == func(mid)) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        return res_L ? BSR(true, L, lb) : BSR(true, ub, R);
    }
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 2e5 + 10;
int128_t N, K;
int A[MAX_N];

std::unordered_map<int, std::vector<int>> mp;

std::unordered_map<int, int> change;

int top_if[MAX_N];

//int ret[MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N >> K;

    rep (i, 0, N-1) {
        std::cin >> A[i];
        mp[A[i]].push_back(i);
    }

    rev (i, N-1, 0) {
        if (mp[A[i]].back() == i) {
            top_if[i] = A[i];
        } else {
            auto bsr = binary_search(0, mp[A[i]].size() - 1, [&](int j){
                return i < mp[A[i]][j];
            });
            assert(bsr.found);
            if (mp[A[i]][bsr.begin] == N - 1) {
                top_if[i] = 0;
            } else {
                top_if[i] = top_if[mp[A[i]][bsr.begin] + 1];
            }
        }
    }

    /*
    rep (i, 0, N-1) {
        std::cout << top_if[i] << " ";
    }
    std::cout << std::endl;
    */

    change[0] = top_if[0];
    for (auto p : mp) {
        if (p.second[0] == N - 1) {
            change[p.first] = 0;
        } else {
            change[p.first] = top_if[p.second[0]+1];
        }
    }

    /*
    for (auto p : change) {
        std::cout << p.first << " " << p.second << std::endl;
    }
    */

    int tmp_begin = 0;
    int128_t num = K - 1;
    std::unordered_map<int, int> tmp_change = change;
    while (num > 0) {
        if (num & 1) { tmp_begin = tmp_change[tmp_begin]; }
        std::unordered_map<int, int> copy = tmp_change;
        for (auto p : tmp_change) {
            tmp_change[p.first] = copy[copy[p.first]];
        }
        num = (num >> 1);
    }

    //std::cout << tmp_begin << std::endl;

    std::vector<int> ret;
    std::set<int> st;
    int start = 0;

    if (tmp_begin != 0) {
        //ret.push_back(tmp_begin);
        //st.insert(tmp_begin);
        start = mp[tmp_begin][0] + 1;
    }

    rep (i, start, N-1) {
        if (st.count(A[i])) {
            while (true) {
                if (ret.back() == A[i]) {
                    st.erase(ret.back());
                    ret.pop_back();
                    break;
                } else {
                    st.erase(ret.back());
                    ret.pop_back();
                }
            }
        } else {
            ret.push_back(A[i]);
            st.insert(A[i]);
        }
    }

    for (int i : ret) {
        std::cout << i << " ";
    }
    std::cout << std::endl;

    /*
    std::unordered_map<int, int> pos;
    int size = 0;

    if (tmp_begin != 0) {
        ret[0] = tmp_begin;
        pos[tmp_begin] = 0;
        size++;
    }

    rep (i, 0, N-1) {
        if (pos.count(A[i])) {
            size = pos[A[i]];
            pos.erase(A[i]);
        } else {
            std::cout << i << " " << size << " " << A[i] << std::endl;
            ret[size] = A[i];
            pos[A[i]] = size;
            size++;
        }
        //std::cout << i << " " << A[i] << " " << size << " " << ret[0] << " " << ret[1] << std::endl;
    }

    rep (i, 0, size - 1) {
        std::cout << ret[i] << " ";
    }
    std::cout << std::endl;
    */


    return 0;
}

Measured memory_bytes: 47304