/*
23280701537353
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200009;
int n;
ll k;
int a[N],focc[N],par[N];
vector<int> ans,v1;
stack<int> stk;
bool vis[N];
vector< vector<int> >v(N);
int get_par(int no)
{
   if(par[no]==no)
        return no;
    return par[no]=get_par(par[no]);
}
void I()
{
    for(int i=0;i<=200005;i++)
        par[i]=i,focc[i]=N;
}
void lnk(int a,int b)
{
    par[a]=b;
}
int main()
{

    cin>>n>>k;
    I();
   for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        v[a[i]].pb(i);
    }
    for(int i=1;i<=200000;i++)
    {
        for(int j=0;j<sz(v[i]);j++)
        {
            int p1=v[i][j];
            int p2=v[i][j];
            if(j+1<sz(v[i]))
               p2=v[i][j+1]+1;
            if(p2>n)
                p2=0;
            lnk(p1,p2);
        }
    }
    focc[0]=0;
    for(int i=1;i<=n;i++)
    {
        focc[a[i]]=min(focc[a[i]],i);
    }

    int pre=0,cy=0;
    while(1)
    {
        if(vis[pre])
        {
            cy=pre;
            break;
        }
        vis[pre]=1;
        v1.pb(pre);
        int cur=(focc[pre]+1>n?0:focc[pre]+1);
        pre=a[get_par(cur)];
    }

    int beg=-1,str=0;
    for(int i=0;i<sz(v1);i++)
    {
        if(v1[i]==cy)
        {
            str=i;
            break;
        }
        if(k==i+1)
            beg=v1[i];
    }
    if(beg==-1)
    {
        k-=str;
        int siz=sz(v1)-str;
       // cout<<(k-1)%siz+cy<<" "<<siz<<endl;
        beg=v1[(k-1)%siz+cy];
    }

    str=focc[beg]+1;
    if(str>n)
    {
        cout<<endl;
        return 0;
    }
    clr(vis,0);
    for(int i=str;i<=n;i++)
    {
        if(vis[a[i]])
        {
            while(sz(stk)>0&&vis[a[i]])
            {
                int cur=stk.top();
                stk.pop();
                vis[cur]=0;

            }
        }
        else
            stk.push(a[i]),vis[a[i]]=1;
    }
    while(sz(stk)>0)
    {
        ans.pb(stk.top());
        stk.pop();
    }
    for(int i=sz(ans)-1;i>=0;i--)
    {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 17092