//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk

using namespace std;

inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }

const int N = 200000 + 1;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

vector<int> position[N];
bool was[N];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    /*int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    set<int> used;
    vector<int> st;
    cout << "\n";
    rep(t, 0, 10) {
        rep(i, 0, n) {
            if (used.count(a[i])) {
                while (used.count(a[i])) {
                    used.erase(st.back());
                    st.pop_back();
                }
            } else {
                used.insert(a[i]);
                st.push_back(a[i]);
            }
        }
        for (int i : st) {
            cout << i << " ";
        }
        cout << "\n";
    }*/
    int n; ll k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, 0, n) {
        position[a[i]].push_back(i);
    }
    pair<int, int> go[n];
    rep(i, 0, n) {
        int p = lower_bound(position[a[i]].begin(), position[a[i]].end(), i) - position[a[i]].begin();
        if (p + 1 < sz(position[a[i]])) {
            int to = position[a[i]][p + 1] + 1, w = 0;
            if (to == n) {
                to = 0;
                w++;
            }
            go[i] = {to, w};
        } else {
            int to = position[a[i]][0] + 1, w = 1;
            if (to == n) {
                to = 0;
                w++;
            }
            go[i] = {to, w};
        }
    }
    vector<bool> used(n, false);
    vector<ll> tot(n, 0);
    ll num = 1; int pos = 0;
    bool jump = false;
    while (true) {
        used[pos] = true;
        tot[pos] = num;
        if (num + go[pos].se > k) {
            break;
        }
        num += go[pos].se;
        pos = go[pos].fi;
        if (used[pos] && !jump) {
            jump = true;
            num += (k - num) / (num - tot[pos]) * (num - tot[pos]);
        }
    }

    vector<int> st;
    while (num <= k) {
        if (!was[a[pos]]) {
            st.push_back(a[pos]);
            was[a[pos]] = true;
        } else {
            while (was[a[pos]]) {
                was[st.back()] = false;
                st.pop_back();
            }
        }
        pos++;
        if (pos == n) {
            pos = 0;
            num++;
        }
    }
    for (int i : st) {
        cout << i << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 17528