//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()


using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;

const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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;
}


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    LL N; cin >> N;
    LL K; cin >> K;
    LL L = 60;

    map<int,VI> key_id; //key_id

    //vector<VLL> next(L+1,tmp);

    // input, next[0][]
    VI A(N);
    VLL W(N);
    //VI B(N);

    REP(i,2*N){
        
        if(i<N){
            cin >> A[i];
            //A[N+i]=B[i]; // 1 2 3 2 3 1 2 3 2 3
        }
        
        // same exist before
        int a = A[i%N];
        if(key_id.count(a)!=0){
            int id = key_id[a].back(); //- - - 1 2, 0 3 4 ..  
            DPRINT(id);
            if (id<N) W[id] = i - id + 1;
        }
        // add key
        key_id[a].PB(i);
         //several id for one key
    }    

    VVLL next(L+1,W);
    // doubling
    REP(k,L){
        REP(i,N){
            LL nowid = i + next[k][i];
            LL nextid = nowid + next[k][nowid%N];
            next[k+1][i] = min(LINF,nextid - i); //= next[k][i] + next[k][nowid%N]
        }
    }

    /* 
    //change out of range to -1
    REP(k,max_k+1){
        REP(i,N){
            if(next[k][i]+i > N*K) next[k][i] = -1;
        }
    }
    */

    //start from id = 0
    LL gid = 0; // global id
    CIREP(k,L,0){
        DPRINT(k)
        int id = gid%N; // id in a Line
        LL nextid = gid + next[k][id];
        //DPRINT(nextid)
        if(nextid <= N*K){
            gid = nextid;
        }
        //DPRINT(id)
    }

    // Do as the task
    if(gid==N*K) return;
    int id = gid%N;
    DPRINT(id)
    VI ans;

    //gidが負になるエラーがこれで防げる
    //chmax(id,0);

    CREP(i,id,N-1){

        //already deleted
        int stop_id = next[0][i] + i - 1;
        
        if(next[0][i]==-1){
            continue;
        }
        
        //do not appear
        if(stop_id >= N){
            DPRINT(i)
            //int a = B[i];
            ans.PB(A[i]); //error here
        }
        //appear
        else{
            CREP(j,i+1,stop_id){ //stop max = N-1
                DPRINT(j)

                //error access here
                next[0][j] = -1; //delete
            }
        }
        
        
    }
    REP(i,SZ(ans)){
        cout << ans[i];
        if(i< SZ(ans)-1) cout << " ";
        else cout <<endl;
    }
}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 122100