#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cassert>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int N, K;
vector<int> A;
int nextIdx[200010];

void calcNextIdx() {
    unordered_map<int, int> m;
    for (int i = N - 1; i >= 0; i--) {
        auto it = m.find(A[i]);
        if (it != m.end()) {
            nextIdx[i] = it->second;
        }
        m[A[i]] = i;
    }
    for (int i = N - 1; i >= 0; i--) {
        auto it = m.find(A[i]);
        if (it != m.end()) {
            nextIdx[i] = it->second;
        }
        m[A[i]] = i;
    }
}

bool inserted[200010];

signed main() {
    cin >> N >> K;

    inputVector(A, N);

    calcNextIdx();

    int loop = 0;
    int now = 0;
    int target = -1;
    unordered_map<int, int> m, rm;
    m[N - 1] = 0;
    rm[0] = N - 1;
    //fprintf(stderr, " m[%lld] = 0\n", N - 1);
    while (true) {
        int next = nextIdx[now];
        if (next <= now || next == N - 1) {
            loop++;
            if (loop == K) {
                target = now;
                break;
            }
            if (m.find(next) != m.end()) {
                //cerr << "  next = " << next << endl;
                int start = m[next];
                int period = loop - m[next];
                int left = K - start - 1;
                if (now == next && now == N - 1) {
                    period++;
                }
                //fprintf(stderr, "start:%lld period:%lld left:%lld\n", start, period, left);
                left %= period;
                //fprintf(stderr, " -> left:%lld\n", left);
                if (now == next && now == N - 1 && left == period - 1) {
                    target = N;
                } else {
                    target = rm[start + left] + 1;
                    if (now == next && now == N - 1 && target == N) {
                        target = 0;
                    }
                }
                break;
            }
            m[next] = loop;
            rm[loop] = next;
            //fprintf(stderr, " m[%lld] = %lld\n", next, loop);
        }
        //fprintf(stderr, "now:%lld next:%lld loop:%lld\n", now, next, loop);
        now = next + 1;
        if (now == N) now = 0;
    }

    assert(target != -1);
    //cerr << "target = " << target << endl;

    vector<int> ret;
    REP(i, target, N - 1) {
        if (inserted[A[i]]) {
            while (!ret.empty() && ret.back() != A[i]) {
                inserted[ret.back()] = false;
                ret.pop_back();
            }
            if (!ret.empty()) {
                inserted[ret.back()] = false;
                ret.pop_back();
            }
        } else {
            ret.push_back(A[i]);
            inserted[A[i]] = true;
        }
    }

    for (auto v : ret) cout << v << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 24308