#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const int N=200000;

int n,a[N+9];
LL m;
vector<int>p[N+9];

void into(){
  scanf("%d%lld",&n,&m);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int fir[N+9],last[N+9],nxt[N+9];

void Get_nxt(){
  for (int i=1;i<=n;++i){
	if (!fir[a[i]]) fir[a[i]]=i;
	if (last[a[i]]) nxt[last[a[i]]]=i;
	last[a[i]]=i;
  }
  for (int i=1;i<=N;++i)
	if (fir[a[i]]) nxt[last[a[i]]]=fir[a[i]];
}

int vis[N+9],ans[N+9],ca;

void Get_ans(int p){
  for (int i=p;i<=n;++i)
	if (vis[a[i]]){
	  for (;ca&&vis[a[i]];--ca) vis[ans[ca]]=0;
	}else vis[ans[++ca]=a[i]]=1;
}

void Get_ans(){
  int cnt=0;
  for (int k=1;2333;){
	if (nxt[k]<=k) ++cnt;
	if ((k=nxt[k])==n) {++cnt;break;}
	++k;
  }
  m%=cnt;
  if (!m) return;
  for (int k=1;2333;){
	if (m==1) {Get_ans(k);return;}
	if (nxt[k]<=k) --m;
	k=nxt[k]+1;
  }
}

void work(){
  Get_nxt();
  Get_ans();
}

void outo(){
  for (int i=1;i<=ca;++i)
	printf("%d ",ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}