// behold, the single dinosaur code that will be the most dated and inaccessible to future
// generations!!
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
using ll = int64_t;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T, typename U> ostream& operator<<(ostream& _s, pair<T, U> _t) {
    _s << "(" << _t.first << "," << _t.second << ")"; return _s;
}
template<typename T, typename U> istream& operator>>(istream& _s, pair<T, U> &_t) {
    _s >> _t.first >> _t.second; return _s;
}
template<typename T> ostream& operator<<(ostream& _s, vector<T> _t) {
    rep(i, 0, _t.size()) _s << (i ? " " : "") << _t[i]; return _s;
}
template<typename T> istream& operator>>(istream& _s, vector<T> &_t) {
    rep(i, 0, _t.size()) _s >> _t[i]; return _s;
}

const int LOG = 50;
const int N = 2e5+10;
const ll K = 1e12;
int jmp[LOG][N];
ll dist[LOG][N];

vector<int> sim(vector<int>& v) {
    unordered_set<int> have;
    vector<int> cur;
    for(auto x : v) {
        // cout << x << " | " << cur << endl;
        if (have.count(x)) {
            while (true) {
                // if (cur.empty()) {while(1) {}}
                int last = cur.back();
                cur.pop_back();
                have.erase(last);
                if (last == x) {
                    break;
                }
            }
        } else {
            cur.push_back(x);
            have.insert(x);
        }
    }
    return cur;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;

    unordered_map<int, vector<int>> occ;

    rep(i,0,n) {
        occ[a[i]].push_back(i);
    }

    for(auto& x : occ) {
        rep(i,0,x.second.size()) {
            int cur = x.second[i];
            int nxt = x.second[(i+1)%x.second.size()];
            jmp[0][cur] = (nxt + 1) % n;
            dist[0][cur] = nxt - cur + 1;
            if (dist[0][cur] <= 1) dist[0][cur] += n;
        }
    }

    rep(l,1,LOG) {
        rep(i,0,n) {
            jmp[l][i] = jmp[l-1][jmp[l-1][i]];
            dist[l][i] = min(dist[l-1][i] + dist[l-1][jmp[l-1][i]], N*K+10);
        }
    }

    // rep(l,0,3){
    //     cout << "----------- " << l << endl;
    //     rep(i,0,n) {
    //         cout << i << ": " << jmp[l][i] << " " << dist[l][i] << endl;
    //     }
    // }

    int cur = 0;
    ll rem = n * k;
    per(l,0,LOG) {
        if (dist[l][cur] <= rem) {
            // cout << "jump " << l << " " << cur << " " << jmp[l][cur] << " " << rem << endl;
            rem -= dist[l][cur];
            cur = jmp[l][cur];
            l++;
        }
    }

    // assert(rem <= N*2);

    vector<int> rest;

    while (rem > 0) {
        rem--;
        rest.push_back(a[cur]);
        cur = (cur + 1) % n;
    }
    vector<int> res = sim(rest);

    cout << res << endl;

    // vector<int> asdf = {1,2,3,1,2,3};
    // cout << sim(asdf) << endl;
}


Measured memory_bytes: 145736