#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k,a[200010];
    vll G[200010];
    cin>>n>>k;
    rep(i,n){
        cin>>a[i];
        G[a[i]].pb(i);
    }
    ll t=0,cnt=1;
    ll now=a[0],i=0;
    while(true){
        auto itr=upper_bound(all(G[now]),i);
        // cout<<now<<"###"<<*itr<<endl;
        if(itr==G[now].end()){
            i=G[now][0]+1;
            now=a[G[now][0]+1];
            cnt++;
            if(i==n){
                t=cnt;
                // cout<<t<<endl;
                break;
            }
            // cout<<"yes"<<now<<" "<<i<<endl;
        }
        else if(*itr==n-1){
            t=cnt;
            break;
        }
        else{
            now=a[*itr+1];
            i=*itr+1;
        }
    }
    k%=t;
    now=a[0],i=0;
    cnt=1;
    // cout<<"k"<<k<<endl;
    if(k==0){
        cout<<endl;
        return 0;
    }
    while(k!=1){
        auto itr=upper_bound(all(G[now]),i);
        // cout<<now<<"###"<<*itr<<endl;
        if(itr==G[now].end()){
            i=G[now][0]+1;
            now=a[G[now][0]+1];
            cnt++;
            if(cnt==k){
                break;
            }
            // cout<<"yes"<<now<<" "<<i<<endl
        }
        else if(*itr==n-1){
            t=cnt;
        }
        else{
            now=a[*itr+1];
            i=*itr+1;
        }
    }
    vll v;
    rep2(j,i,n){
        auto itr=upper_bound(all(G[a[j]]),j);
        if(itr==G[a[j]].end()){
            v.pb(a[j]);
        }
        else{
            j=*itr;
        }
    }
    if(v.empty()) cout<<endl;
    else{
        rep(i,v.size()){
            cout<<v[i];
            if(i!=v.size()-1) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 15732