#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=2e5+5;
ll n,m,top,a[N],fst[N],lst[N],nxt[N],vis[N],s[N],ans[N],k;

int main() {
  cin >> n >> k;
  for(ll i=1;i<=n;i++) {
    cin >> a[i];
    if(!fst[a[i]]) fst[a[i]]=i;
  }
  nxt[n+1]=1;
  for(ll i=n;i;i--) {
    if(!lst[a[i]]) nxt[i]=fst[a[i]]+1; 
    else nxt[i]=nxt[lst[a[i]]+1];
    lst[a[i]]=i;
  }
  for(ll i=1;!vis[i];i=nxt[i]) {
    vis[i]=1;
    s[++m]=i;
  }
  memset(vis,0,sizeof(vis));
  for(ll i=s[(k-1)%m+1];i<=n;i++) {
    if(!vis[a[i]])ans[++top]=a[i],vis[a[i]]=1;
    else {
      do{
        vis[ans[top--]]=0;
      } while(ans[top+1]!=a[i]);
    }
  }
  for(ll i=1;i<=top;i++) {
    if(i!=1) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}