#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
ll table[500005];
ll modans[500005];
ll table_num;
char s[500005];
ll check[500005];
ll aim[500005];

void action(){
    ll used[200005];
    for(int i=0;i<=200000;i++){
        used[i] = 0;
    }
    ll table_copy[200005];
    ll action_num = 0;
    for(int i=0;i<table_num;i++){
        //looking at value
        ll look = table[i];
        if(used[look] == 0){
            table_copy[action_num++] = look;
            used[look]++;
        }else{
            used[look] = 0;
            while(1){
                action_num--;
                if(table_copy[action_num] == look){
                    table_copy[action_num] = 0;
                    break;
                }else{
                    used[table_copy[action_num]] --;
                    table_copy[action_num] = 0;
                }
            }
        }
    }
    for(ll i=0;i<action_num;i++){
        table[i] = table_copy[i];
    }
    table_num = action_num;
    return;
}

void chase_init(){
    for(i=0;i<n+n;i++){
        if(check[y[i]]){
            //きたことある
            aim[i] = check[y[i]] - 1;
            check[y[i]] = i + 1;
        }else{
            check[y[i]] = i + 1;
        }
    }
    for(i=0;i<n+n;i++){
        //pe("aim")pe(i);pe(" = ");p(aim[i]);
    }

}

int main(){
	cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> x[i];
        y[i] = x[i];
    }
    for(i=n;i<n+n;i++){
        y[i] = x[i-n];
    }
    chase_init();
    ll nowpos = 2*n-1;
    while(1){
        //pe("nowpos = ");p(nowpos);
        ll newpos = aim[nowpos];
        modans[b] = newpos % n;
        //pe("modans[");pe(b);pe("] = ");p(newpos % n);
        num++;
        nowpos = newpos - 1;
        if(nowpos < n){
            b++;
            nowpos += n;
        }
        if(newpos == n || newpos == 0){
            if(newpos == 0)b++;
            break;
        }
    }
    //pe("num = ");p(num);
    //pe("b = ");p(b);
    k %= b;
    ll checkans;
    if(k == 0){
        checkans = 0;
    }else{
        checkans = modans[b - 1 - k];
    }
    //pe("checkans = ");p(checkans);
    for(i=checkans;i<n;i++){
        table[i-checkans] = y[i];
    }
    table_num = n - checkans;
    action();
    for(i=0;i<table_num;i++){
        pe(table[i]);
    }
    el;

	return 0;
}



Measured memory_bytes: 32256