// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll inf = 5e15;

struct Solver {
    V<ll> A, n2idx;
    ll N, K;
    Solver() {
        cin >> N >> K;
        A = V<ll>(N);
        n2idx = V<ll>(2e5 + 10, inf);
        for(ll i = 0; i < N; i++) {
            cin >> A[i];
            chmin(n2idx[A[i]], i);
        }
    }


    ll prefix() {
        V<ll> dyn_idx(2e5 + 10, inf);
        V<ll> prefix_begin(N + 10, 0);
        for(ll i = N - 1; 0 <= i; i--) {
            ll e = A[i];
            if(dyn_idx[e] == inf) {
                prefix_begin[i] = e;
            } else {
                prefix_begin[i] = prefix_begin[dyn_idx[e] + 1];
            }
            dyn_idx[e] = i;
        }

        V<ll> op_of_prefix(2e5 + 10, -1);
        ll prefix_now = 0;

        auto operate = [&] {
            ll idx = n2idx[prefix_now];
            ll nxt_prefix = prefix_begin[(idx == inf ? 0 : idx + 1)];
            return nxt_prefix;
        };

        for(ll i = 1; i < K; i++) {
            ll nxt_prefix = operate();
            if(op_of_prefix[nxt_prefix] != -1) {
                ll loop_cnt = i - op_of_prefix[nxt_prefix];
                ll rest = (K - 1) - i;
                rest %= loop_cnt;
                prefix_now = nxt_prefix;
                for(ll j = 0; j < rest; j++) prefix_now = operate();
                return prefix_now;
            }
            op_of_prefix[nxt_prefix] = i;
            prefix_now = nxt_prefix;
        }

        return prefix_now;
    }
    
    void solve() {
        stack<ll> stk;
        ll prefix_now = prefix();
        DEBUG(prefix_now);
        ll idx = 0;
        if(prefix_now == 0) idx--;
        else while(A[idx] != prefix_now) idx++;
        V<bool> exist(2e5 + 10, false);
        for(ll i = idx + 1; i < N; i++) {
            ll e = A[i];
            if(!exist[e]) {
                stk.push(e);
                exist[e] = true;
            } else {
                while(true) {
                    ll tmp = stk.top();
                    stk.pop();
                    exist[tmp] = false;
                    if(tmp == e) break;
                }
            }
        }
        V<ll> ans;
        while(stk.size()) {
            ans.push_back(stk.top());
            stk.pop();
        }

        reverse(ALL(ans));
        for(ll i = 0; i < ans.size(); i++) cout << ans[i] << " \n"[i + 1 == ans.size()];
    }
};

int main() {
    Solver().solve();
    return 0;
}


Measured memory_bytes: 9900