#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 ll n,k;
  cin>>n>>k;
  
  ll num[n+1];
   ll roop[200005];
   ll point[200005];
  rep(i, n){

    cin>>num[i+1];}
  rep(i, 200005){
        roop[i+1]=0;
    point[i+1]=0;
  }
  
  vector<ll> vec[200005];
 
  vector <ll> route;
  
  for(int i=1;i<=n;i++){
    ll p=num[i];
    vec[p].push_back(i);}
  
  
  ll midround=0;
  ll round=1;
  ll sy=1;
  ll masu=1;
  ll si=0;
  bool last=false;
  
  
  for(int j=1;j<=3*n;j++){
    ll q=num[masu];
    
     roop[masu]=sy;
     si=vec[q].size()-1;
    
 

    if(si==point[q]){
      point[q]=0;
      masu=vec[q][0];
      sy++;}
    else{
      point[q]++;
      masu=vec[q][point[q]];
    }
 
    
    

    
    if(masu<=n-1){
      masu++;}
    else{
      masu=1;
      sy++;}
    
    
    if(roop[masu]>=1){
      midround=roop[masu];
        round=sy-roop[masu];
      break;
    }
    else{
      roop[masu]=sy;}
    
    q=num[masu];

    
    ll l=0;
    q=num[masu];
    ll r=vec[q].size();
    for(int kk=0;kk<=50;kk++){
      ll mid=(l+r)/2;
    if(masu==vec[q][mid]){
      point[q]=mid;
      break;}
      else if(masu<vec[q][mid]){
        if((l+mid)/2!=mid){
      r=mid;}
        else{
          r-=2;}
        
        }
      else{
         if((l+mid)/2!=mid){
      l=mid;}
        else{
          l+=2;}
        
        }
    }

      
    if(sy==k){
      last=true;
      break;}
      
      
  }

 
  
    if(midround+round<=k){
      k=k-(midround+round*((k-midround)/round))+1;}
  
  ll kai=1;
  ll q=num[masu];

  

    ll l=0;
    ll r=vec[q].size()-1;
    for(int kk=0;kk<=50;kk++){
      ll mid=(l+r)/2;
     if(masu==vec[q][mid]){
      point[q]=mid;
      break;}
      else if(masu<vec[q][mid]){
        if((l+mid)/2!=mid){
      r=mid;}
        else{
          r-=2;}
        
        }
      else{
         if((l+mid)/2!=mid){
      l=mid;}
        else{
          l+=2;}
      
      
      
    }
    }

  
     if(last){
    k=1;
     }
 
 
  while(kai<k){
     ll q=num[masu];
     si=vec[q].size()-1;
    if(si==point[q]){
      point[q]=0;
      masu=vec[q][0];
      kai++;}
    else{
      point[q]++;
      masu=vec[q][point[q]];
    }
    
    
    if(masu<=n-1){
      masu++;}
    else{
      masu=1;
      kai++;}
    
    
    ll l=0;
    q=num[masu];
    ll r=vec[q].size()-1;
    for(int kk=0;kk<=50;kk++){
      ll mid=(l+r)/2;
    if(masu==vec[q][mid]){
      point[q]=mid;
      break;}
      else if(masu<vec[q][mid]){
        if((l+mid)/2!=mid){
      r=mid;}
        else{
          r-=2;}
        
        }
      else{
         if((l+mid)/2!=mid){
      l=mid;}
        else{
          l+=2;}
    }

    
    }
    
  }
  

  vector <ll> sig{};
  ll cnt[200005];
  rep(i, 200005){
    cnt[i+1]=-1;}
  
  for(int i=masu;i<=n;i++){
    int a=num[i];
   
    sig.push_back(a);
     int www=sig.size()-1;
    if(cnt[a]==-1){
      cnt[a]=www;}
    else{
      int ppp=cnt[a];
      for(int j=www;j>=ppp;j--){
        ll aaa=sig[j];
        cnt[aaa]=-1;
      sig.pop_back();
      }
      
    }
  
  }
  
  
  if(sig.size()==0){
    return 0;
  }
  
  for(int i=0;i<=sig.size()-1;i++){
    if(i!=sig.size()-1){
  cout<<sig[i]<<" ";}
    else{
      cout<<sig[i]<<endl;}
  }
  
  return 0;
    
    
 
}


Measured memory_bytes: 20340