#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,k;
  cin >> n >> k;
  vector<LL> a(n);
  for(LL &x:a) cin >> x;
  vector<LL> first(212345,-1);
  vector<LL> last(212345,-1);
  vector<LL> succ(n,-1);
  REP(i,n) {
    if(first[a[i]] == -1) first[a[i]] = i;
    if(last[a[i]] != -1) succ[last[a[i]]] = i;
    last[a[i]]=i;
  }

  vector<LL> answers;
  LL tmpans = n;
  do {
    answers.push_back(tmpans);
    LL pos = (tmpans == n) ? 0 : first[a[tmpans]]+1;
    while(true) {
      if(pos==n) break;
      if(succ[pos]==-1) break;
      else pos = succ[pos]+1;
    }
    tmpans = pos;
  } while(tmpans != n);
  LL from = answers[k%answers.size()];
  vector<LL> res;
  set<LL> nums;
  FOR(i,from,n) {
    if(nums.count(a[i])) {
      while(res.back() != a[i]) {
        nums.erase(res.back());
        res.pop_back();
      }
      nums.erase(res.back());
      res.pop_back();
    } else {
      res.push_back(a[i]);
      nums.insert(a[i]);
    }
  }
  REP(i, res.size()) {
    if(i) cout << " ";
    cout << res[i];
  }
  cout << endl;
}
