#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;
using ll = long long int;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }

ll N,K;
deque<ll> A;
map<ll,vector<ll>> cnt;
void input(){
    fast_io();
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        cnt[a].push_back(i);
        A.push_back(a);
    }
}

deque<ll> next_step(deque<ll> d){
    deque<ll> Dq = d;
    set<ll> se;
    for (int i = 0; i < d.size(); i++) se.insert(d[i]);
    
    for (int i = 0; i < N; i++)
    {
        if(se.find(A[i])==se.end()) {Dq.push_back(A[i]);se.insert(A[i]);}
        else{
            while(Dq.back()!=A[i] && !Dq.empty()) {se.erase(Dq.back()); Dq.pop_back();}
            se.erase(A[i]);
            Dq.pop_back();
        }
    }
    return Dq;
}

int TLEsolve(){
    deque<ll> Dq;
    ll l=0;
    DBG(A)
    // ココを効率化したい。
    do
    {
        Dq = next_step(Dq);
        DBG(Dq)
        l++;
    } while (!Dq.empty());
    
    if(l==1) {cout << " " << endl; return 0;}
    ll r = K%l;    
    while(r--) Dq = next_step(Dq);
    cout << Dq << endl;
    return 0;
}
// ダブリングで解く。
int solve(){
    // g[k][i] := (i=i+g(i)と置き換える操作を2^k回行ったあとのi)-i
    // g[0][i]を求める。
    // g[k+1][i] = g[k][g[k][i]%N]
    // a[0][i] = A[i]の数字を先頭とするブロックの要素数。
    // a[k][i] = A[i]の数字を先頭とする2^k個のブロックの要素総数
    // a[k+1][i] = a[k][i] + a[k][(i+a[k][i])%N]
    vector<vector<ll>> d(70,vector<ll>(N,0));
    for (int i = 0; i < N; i++)
    {
        auto itr = upper_bound(cnt[A[i]].begin(),cnt[A[i]].end(),i);
        if(itr!=cnt[A[i]].end()) d[0][i] = *itr-i+1;
        else d[0][i] = cnt[A[i]][0]+N-i+1;
    }
    DBG(d[0])
    for (int k = 0; k < 64; k++)
    {
        for (int i = 0; i < N; i++) {
            if(d[k][i]>N*K) d[k+1][i] = d[k][i];
            else d[k+1][i] = d[k][i] + d[k][(i+d[k][i])%N];
            }
    }
    ll a=0;
    int k = 64;
    while(k--){
        if(a+d[k][a%N]<N*K) a += d[k][a%N];
    }
    DBG(a)
    // 最後はシュミレーション
    deque<ll> Dq;
    set<ll> se;
    for (int i = a%N; i < N; i++)
    {
        if(se.find(A[i])==se.end()) {Dq.push_back(A[i]);se.insert(A[i]);}
        else{
            while(Dq.back()!=A[i] && !Dq.empty()) {se.erase(Dq.back()); Dq.pop_back();}
            se.erase(A[i]);
            Dq.pop_back();
        }
    }
    for(auto elem:Dq) cout << elem << " "; cout << endl;
    return 0;
    
}

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 145508