#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K;
  cin>>N>>K;
  ll A[N];
  REP(i,N) cin>>A[i];
  
  ll DP[200010],LAST[200010];
  REP(i,200010){
    LAST[i]=INF;
    DP[i]=0;
  }
  for(int i=N-1; i>=0; --i){
    if(LAST[A[i]]==INF) DP[i]=A[i];
    else DP[i]=DP[LAST[A[i]]+1];
    LAST[A[i]]=i;
  }
  
  ll P[200010];
  P[0]=DP[0];
  RREP(i,200009){
    if(LAST[i]==INF) P[i]=i;
    else P[i]=DP[LAST[i]+1];
  }
  
  ll R[200010],cnt=0;
  R[0]=0;
  while(1!=0){
    cnt++;
    R[cnt]=P[R[cnt-1]];
    if(R[cnt]==0) break;
  }
  
  K%=cnt;
  if(K==0) co("");
  else{
    ll CNT[200010];
    REP(i,200010) CNT[i]=0;
    stack<ll> Q;
    if(K!=1){
      Q.push(R[K-1]);
      CNT[R[K-1]]++;
    }
    
    for(int i=0; i<N; ++i){
      if(CNT[A[i]]>0){
        while(Q.top()!=A[i]){
          ll v=Q.top();
          Q.pop();
          CNT[v]--;
        }
        Q.pop();
        CNT[A[i]]--;
      }
      else{
        Q.push(A[i]);
        CNT[A[i]]++;
      }
    }
    
    ll ANS[200010];
    RREP(i,200009) ANS[i]=INF;
    
    for(int i=200000; i>0; --i){
      if(Q.size()>0){
        ll v=Q.top();
        Q.pop();
        ANS[i]=v;
      }
      else break;
    }
    
    bool CAN=false;
    for(int i=1; i<=200000; ++i){
      if(ANS[i]!=INF){
        cout<<ANS[i]<<" ";
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 13496