#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

ll rec(ll n,ll v,ll i,vector<vector<pair<ll,ll>>> &x,const vector<ll> &a){
    auto itr = lower_bound(x[v].begin(),x[v].end(),make_pair(i,-INF));
    
    if((*itr).second >= 0){
        return (*itr).second;
    }else{
        auto tmp = itr;
        ++itr;
        if(itr == x[v].end()){
            return v;
        }
        if((*itr).first == n-1){
            return ((*tmp).second = 0);
        }
        return ((*tmp).second = rec(n,a[(*itr).first + 1],(*itr).first + 1,x,a));
    }
}

ll mysearch(ll n,ll v,vector<vector<pair<ll,ll>>> &x,const vector<ll> &a){
    if(v < 0){
        return rec(n,a[0],0,x,a);
    }else{
        auto itr = lower_bound(x[v].begin(),x[v].end(),make_pair(0LL,-INF));
        if((*itr).first == n-1){
            return 0;
        }else{
            rec(n,a[(*itr).first + 1],(*itr).first + 1,x,a);
        }
    }
}

void solve(ll n,ll v,vector<ll> &a){
    unordered_map<ll,ll> mp;

    vector<ll> ans(n+1,0);
    ll idx = 0;
    mp.insert({v,idx});
    for(int i = 0; i < n; i++){
        if(mp.find(a[i]) == mp.end()){
            mp.insert({a[i],idx});
            ans[idx] = a[i];
            idx++;
        }else{
            ll nextidx = mp[a[i]];
            for(int j = idx; j >= nextidx; j--){
                mp.erase(ans[j]);
                ans[j] = 0;
            }
            if(mp.find(a[i]) != mp.end()){
                mp.erase(a[i]);
            }
            idx = nextidx;
        }
    }
    for(int i = 0; i < idx; i++){
        if(i > 0)cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<list<ll>> tv(2*100000 + 1);

    for(int i = 0; i < n; i++){
        tv[a[i]].push_back(i);
    }

    vector<vector<pair<ll,ll>>> x;

    for(int i = 0; i <= 2*100000; i++){
        vector<pair<ll,ll>> t;
        for(auto itr = tv[i].begin(); itr != tv[i].end(); itr++){
            t.push_back({*itr,-1});
        }
        x.push_back(t);
    }

    vector<ll> next(2*100000 + 1,-1);
    next[0] = mysearch(n,-1,x,a);

    for(int i = 1; i <= 2*100000; i++){
        if(x[i].size() > 0){
            next[i] = mysearch(n,i,x,a);
        }
    }

    /*for(int i = 0; i < 10; i++){
        cerr << next[i] << endl;
    }*/

    ll count = 0;
    unordered_map<ll,ll> mp;

    ll cyclelen = 0;
    ll untcycle = 0;

    ll cur = 0;

    mp.insert({cur,count++});

    while(true){

        if(count == k){
            solve(n,cur,a);
            return 0;
        }

        cur = next[cur];

        if(mp.find(cur) == mp.end()){
            mp.insert({cur,count++});
        }else{
            cyclelen = count - mp[cur];
            untcycle = mp[cur];
            break;
        }
    }

    /*cerr << cyclelen << " ";
    cerr << untcycle << endl;*/


    k -= untcycle;

    ll rest = k - (k/cyclelen)*cyclelen;
    if(rest <= 0){
        rest += cyclelen;
    }

    while(rest > 1){
        rest--;
        cur = next[cur];
    }

    //cerr << cur << endl;

    solve(n,cur,a);

    return 0;
}

Measured memory_bytes: 41644