#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}


vector<int> naive_solve(long long N, long long K, std::vector<long long> A) {

    set<int> C;

    vector<int> S;

    for (int i = 0; i < N * K; i++) {
        if (C.count(A[i % N])) {
            while (true) {
                int v = S.back();
                C.erase(v);
                assert(S.size() > 0);
                S.pop_back();

                if (v == A[i % N]) break;
            }

        } else {
            S.push_back(A[i % N]);
            C.insert(A[i % N]);
        }
    }
    return S;
}

vector<long long> B[200010];
vector<long long> AA;
int dp[400010];

int nxt(int p) {
    if (p >= AA.size()) {
        return p; // possible to be p == A.size() * 2
    }
    if (dp[p] != -1) return dp[p];
    return dp[p] = nxt(*upper_bound(B[AA[p % AA.size()]].begin(), B[AA[p % AA.size()]].end(), p) + 1);
}


long long apply(int N, long long K, vector<vector<pair<long long, long long>>> perm) {
    int p = 0;
    long long V = N * K;
    for (int i = 39; i >= 0; i--) {
        if (perm[i][p].second <= V) {
            V -= perm[i][p].second;
            p = perm[i][p].first;
            i++;
        }
    }
    return V;
}

vector<int> solve(long long N, long long K, std::vector<long long> A) {
    if (K < 3) {
        return naive_solve(N, K, A);
    }

    AA = A;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < 200010; i++) B[i].clear();
    for (int i = 0; i < 2 * N; i++) {
        B[A[i % N]].push_back(i);
    }

    vector<vector<pair<long long, long long>>> perm(40, vector<pair<long long, long long>>(N));

    for (int i = 0; i < N; i++) {
        perm[0][i] = {nxt(i) % N, nxt(i) - i};
    }

    for (int i = 1; i < 40; i++) {
        for (int j = 0; j < N; j++) {
            perm[i][j] = {
                    perm[i - 1][perm[i - 1][j].first].first,
                    perm[i - 1][j].second + perm[i - 1][perm[i - 1][j].first].second
            };
        }
    }
//    cout << "====" << endl;
//    for(int i = 0 ; i < N ; i++){
//        cout << i << ":";
//        cout << perm[0][i].first << " " << perm[0][i].second << "(" << nxt(i);
//        cout << endl;
//    }

    auto lst = apply(N, K, perm);
    vector<long long> real;

    for (int i = N - lst; i < N; i++) real.push_back(A[i]);

    return naive_solve(real.size(), 1, real);


}


int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N - 1 - 0 + 1);
    for (int i = 0; i < N - 1 - 0 + 1; i++) {
        scanf("%lld", &A[i]);
    }
    for( auto x : solve(N, K, A)) cout << x << " "; cout << endl;
//    for (auto i : solve(N, K, A)) {
//        cout << i << " ";
//    }
//    cout << endl;
//
//    for(int i = 1 ; i < 20 ; i++){
//        cout << i << ":";
//        for( auto x : naive_solve(N, i, A)){
//            cout << x << " ";
//        }
//        cout << endl;
//    }
//    for(int i = 1 ; i < 20; i++){
//        cout << i << ":";
//        for( auto x : solve(N, i, A)){
//            cout << x << " ";
//        }
//        cout << endl;
//    }

    return 0;
}


Measured memory_bytes: 267592