#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
using namespace std;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
#define ll long long
class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

					 // Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};
typedef pair<long long, long long>p;
long long mod = 998244353;
long long calc(long long k) {
	return k*(k + 1) / 2;
}
class BIT
{
public:
	vector<int> bit;
	int M;

	BIT(int M) :
		bit(vector<int>(M + 1, 0)), M(M) {}

	int sum(int i) {
		if (!i) return 0;
		if (i == 0)return 0;
		return bit[i] + sum(i - (i&-i));
	}

	void add(int i, int x) {
		if (i > M) return;
		bit[i] += x;
		add(i + (i&-i), x);
	}
};
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	long long n, k;
	int a[200004];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int start[200004];
	start[n - 1] = a[n - 1];
	map<int, int>ma;
	ma[a[n - 1]] = n - 1;
	for (int i = n - 2; i >= 0; i--) {
		if (ma.find(a[i]) == ma.end()) {
			start[i] = a[i];
			ma[a[i]] = i;
		}
		else {
			int pos = ma[a[i]]+1;
			if (pos == n) {
				start[i] = 0;
			}
			else {
				start[i] = start[pos];
			}
			ma[a[i]] = i;
		}
	}
	vector<int>vec;
	vec.push_back(0);
	int now = 0;
	map<int, int>arr;
	arr[0] = 0;
	int end,ind;
	while (1) {
		int next;
		if (now == 0) {
			next = start[0];
		}
		else {
			int x = ma[now] + 1;
			if (x == n)next = 0;
			else {
				next = start[x];
			}
		}
		if (arr.find(next) != arr.end()) {
			int rs = arr.find(next)->second;
			int rt = vec.size()-1;
			k -= 1;
			if (k < rs) {
				ind = vec[k];
			}
			else {
				k -= rs;
				k %= (rt - rs + 1);
				ind = vec[rs + k];
			}
			break;
		}
		else {
			arr[next] = vec.size();
			now = next;
			vec.push_back(next);
		}
	}
	vector<int>ans;
	int cnt[200004] = { 0 };
	if (ind == 0) {
		end = 0;
	}
	else {
		end = ma.find(ind)->second + 1;
	}
	for (int i = end; i < n; i++) {
		if (cnt[a[i]]>0) {
			while (cnt[a[i]] > 0) {
				cnt[ans[ans.size() - 1]] -= 1;
				ans.pop_back();
			}
		}
		else {
			ans.push_back(a[i]);
			cnt[a[i]] += 1;
		}
	}
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << " ";
	}
}

Measured memory_bytes: 24308