#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    vector<ll> A(N,0);
    vector<ll> D(2*N,0);
    rep(i,N){
        cin>>A[i];
        D[i+N]=A[i];
        D[i]=A[i];
    }
    
    //doubling[i][j]:A[j]を消すための区間の長さ * 2^i
    ll D_MAX=58; //2^D_MAXで辿り着ける
    vector<vector<ll> > doubling(D_MAX+1,vector<ll>(N,0));
    
    //doubling[0][[0,N)]作る
    vector<ll> X[200005]; //X[i]:数字iがある座標
    rep(i,2*N){
        if(sz(X[D[i]]) == 0) X[D[i]].pb(i);
        else{
            doubling[0][(X[D[i]][sz(X[D[i]])-1])%N] = i-X[D[i]][sz(X[D[i]])-1]+1;
            X[D[i]].pb(i);
        }
    }
    
    rep1(i,D_MAX)rep(j,N){
        if(doubling[i-1][(doubling[i-1][j]+j)%N]>N*K - doubling[i-1][j]) doubling[i][j]=N*K+10; //必要ない距離として
        else doubling[i][j] = doubling[i-1][j] + doubling[i-1][(doubling[i-1][j]+j)%N];
    }
    
    ll now=0,sum=0;
    rrep(i,D_MAX+1){
        //次おさまる
        while(sum+doubling[i][now]<=N*K){
            sum+=doubling[i][now];
            now+=doubling[i][now];
            now%=N;
        }
    }
    
    //X[sum]~X[NK-1]でシミュレーション
    vector<ll> s; //数列(重複なし!)
    set<ll> se; //存在を管理
    FOR(i,sum,N*K){
        if(se.find(A[i%N])!=se.ed){
            while(1){
                if(s[sz(s)-1]!=A[i%N]){
                    se.erase(s[sz(s)-1]);
                    s.pop_back();
                }
                else{
                    se.erase(s[sz(s)-1]); //==A[i%N]
                    s.pop_back();
                    break;
                }
            }
        }
        else{
            se.insert(A[i%N]);
            s.pb(A[i%N]);
        }
    }
    
    rep(i,sz(s)) cout<<s[i]<<" ";
}




Measured memory_bytes: 121984