#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 1e6 + 10 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f;
}

ll n, m;

ll a[maxn], last[maxn], nex[maxn], w[maxn], link[maxn], cnt, start;

ll ans[maxn], tot;

ll s[maxn];

ll vis[maxn];

void search(ll now, ll step)
{
	if(vis[now])
	{
		if(vis[now] == cnt) start = now, link[now] = step - s[now];
		return;
	}
	vis[now] = cnt;
	s[now] = step;
	search(nex[now], step + w[now]);
	if(start == now) start = 0;
	if(start) link[now] = link[nex[now]];
	return ;
}

signed main()
{
	scanf("%lld %lld", &n, &m);
	rep(i, 1, n) scanf("%lld", &a[i]);
	rep(i, n + 1, 2 * n) a[i] = a[i - n];
	per(i, 2 * n, 1)
	{
		if(i <= n)
		{
			nex[i] = last[a[i]] % n + 1;
			w[i] = (last[a[i]]) / n - (i - 1) / n;
		}
		last[a[i]] = i;
	}
	rep(i, 1, n) if(!vis[i]) ++cnt, search(i, 0);
	// rep(i, 1, n) printf("%lld %lld %lld\n", nex[i], w[i], link[i]);
	// puts("");
	ll now = 0;
	while(m >= 0)
	{
		// printf("%lld %lld %lld\n", m, now, tot);
		if(!m && now == n) break;
		now = now % n + 1;
		ans[++tot] = a[now];
		if(now == 1) m--;
		if(link[now]) if(m >= link[now]) m %= link[now];
		if(w[now] - (nex[now] == 1) <= m)
		{
			m -= w[now] - (nex[now] == 1);
			tot --, now = nex[now] == 1 ? n : nex[now] - 1;
		}
	}
	rep(i, 1, tot) printf("%lld ", ans[i]);
	return 0;
}