/*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
const string FILENAME = "input";
const int MAXN = 200228;


int n;
long long k;
int a[MAXN];
bool have[MAXN];
set<int> pos[MAXN];


int getnxt(int cur) {
    int f = a[cur];
    auto it = pos[f].upper_bound(cur);
    if (it == pos[f].end()) {
        return n + 1;
    }
    return *it + 1;
}



int val[MAXN];
int nxt[MAXN][65];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //read(FILENAME);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pos[a[i]].insert(i);
    }
    vector<int> st;
   // for (int it = 0; it < 4; it++) {
        for (int i = 0; i < n; i++) {
            if (!have[a[i]]) {
                have[a[i]] = true;
                st.pb(a[i]);
            } else {
                while (st.back() != a[i]) {
                    have[st.back()] = false;
                    st.pop_back();
                }
                have[st.back()] = false;
                st.pop_back();
            }
        }
    //     for (auto x: st) {
    //         cout << x << ' ';
    //     }
    //     cout << endl;
    // }
    if (k == 1) {
        for (auto x: st) {
            cout << x << ' ';
        }
        cout << endl;
        return 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        int kek = getnxt(i);
        //cout << kek << ' ' << a[i] << endl;
        val[i] = (kek == n + 1 ? a[i]: val[kek]);
        //cout << val[i] << endl;
    }
    for (int i = 0; i <= 200000; i++) {
        nxt[i][0] = (pos[i].empty() ? val[0]: val[*pos[i].begin() + 1]);
    }
    for (int f = 1; f <= 60; f++) {
        for (int j = 0; j <= 200000; j++) {
            nxt[j][f] = nxt[nxt[j][f - 1]][f - 1];
        }
    }
    int cur = (st.empty() ? 0: st[0]);
    //cout << st[0] << endl;
    k-= 2;
    for (int f = 60; f >= 0; f--) {
        if (k >= (1LL << f)) {
            cur = nxt[cur][f];
            k -= (1LL << f);
        }
    }
    //cout << cur << endl;
    int f = (pos[cur].empty() ? 0: *pos[cur].begin() + 1);
    memset(have, 0, sizeof(have));
    st.clear();
    for (int i = f; i < n; i++) {
         if (!have[a[i]]) {
            have[a[i]] = true;
            st.pb(a[i]);
        } else {
            while (st.back() != a[i]) {
                have[st.back()] = false;
                st.pop_back();
            }
            have[st.back()] = false;
            st.pop_back();
        }
    }
    for (auto x: st) {
            cout << x << ' ';
        }
        cout << endl;
    return 0;
}


Measured memory_bytes: 73460