#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define lw lower_bound
#define up upper_bound
#define all(v) (v).begin(), (v).end()
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, K, a, A[200010];
int c[200010];
int F[200010];
int T[2000100], P;
V f[200010];
int C, t;
void solve()
{
    FOR(i, 0, N)
    {
        f[A[i]].pb(i);
    }
    int n = 0;
    int temp = 10;
    while (true) {
        int t;
        t = A[n];
        auto it = up(all(f[t]), n);
        if (it == f[t].end()) {
            it = f[t].begin();
            T[C] = t;
            C++;
        }
        // dump(n);
        n = *it + 1;
        if (n == N) {
            C++;
            break;
            //   dump(C);
        }
    }
    K--;
    K %= C;
    if (C == 1)
        return;
    int t = T[K];
    // dump(t);
    int it = f[t][(int)f[t].size() - 1];
    //  cout << it << endl;

    FOR(i, 0, 200010)
    F[i] = 200010;
    int p = 0;
    t = 0;
    //dump(*it);
    FOR(i, it, N)
    {
        //dump(i);
        int a = A[i];
        if (F[a] >= t) {
            F[a] = t;
            c[t] = a;
            t++;
        } else {
            int T = F[a];
            FOR(j, T, t)
            {
                F[c[j]] = 200010;
            }
            t = T;
            F[a] = 200010;
        }
    }
    FOR(i, 0, t)
    {
        cout << c[i] << " ";
    }
    cout << endl;
}


/*
void solve()
{
    bool C = true;
    FOR(i, 0, 200010)
    f[i] = 200010;
    int p = 0;
    FOR(q, 0, K)
    {
        //dump(q);
        FOR(i, 0, N)
        {
            int a = A[i];
            if (f[a] >= t) {
                f[a] = t;
                c[q][t] = a;
                t++;
            } else {
                int T = f[a];
                FOR(i, T, t)
                {
                    f[c[q][i]] = 200010;
                }
                t = T;
                f[a] = 200010;
            }
            
            FOR(i, 0, t)
            {
                cout << c[q][i] << " ";
            }
            cout << endl;
        }
        FOR(i, 0, 200010)
        f[i] = 200010;
        FOR(i, 0, t)
        {
            c[q + 1][i] = c[q][i];
            f[c[q][i]] = i;
        }
        T[q] = t;
        p = q;
        //dump(t);
        if (t == 0) {
            break;
        }
        FOR(i, 0, q)
        {
            if (t == T[i]) {
                bool flag = true;
                FOR(j, 0, t)
                {
                    if (c[q][j] != c[i][j]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    C = false;
                    P = i;

                    break;
                }
            }
        }
        if (!C)
            break;
        
        FOR(i, 0, t)
        {
            cout << c[q][i] << " ";
        }
        cout << endl;
    }
    p++;
    if (!C) {
        p++;
        K -= P;
        int q;
        q = K % (p - P);
        q += P - 1;
        if (q < 0)
            q += p;
        t = T[q];
        //dump(t);
        FOR(i, 0, t)
        {
            cout << c[q][i] << " ";
        }
        cout << endl;

    } else if (p == K) {
        FOR(i, 0, t)
        {
            cout << c[K - 1][i] << " ";
        }
        cout << endl;
    } else {
        int q;
        q = (K) % p;
        q--;
        if (q < 0)
            q += p;
        t = T[q];
        //dump(t);
        FOR(i, 0, t)
        {
            cout << c[q][i] << " ";
        }
        cout << endl;
    }
}*/

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FOR(i, 0, N)
    cin >> A[i];

    solve();
    return 0;
}


Measured memory_bytes: 22528