#define DEBUG
// #define FASTIO

#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

#define F first
#define S second 
#define pb push_back
#define endl "\n"

#ifdef FASTIO

#define pr(x) printf("%d", x)
#define ps    printf(" ")
#define endc  printf("\n")
#define pl(x) printf("%lld", x)
#define pf(x) printf("%lf", x)
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define sf(x) scanf("%lf", &x)
#define IOS 

#endif

#ifndef FASTIO
    #define IOS { ios :: sync_with_stdio(false); cin.tie(0); }
#endif

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, n-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

int a[maxn];
int oc[maxn];
int nx[maxn];
int fi[maxn];
int g[maxn];
bool soc[maxn];
stack < int > S;
vector < int > ans;

void tpu(int x) {
    // cout << x << " ???? " << endl;
    if (!soc[x]) {
        S.push(x);
        soc[x] = true;
    } else {
        while (S.top() != x) {
            int z = S.top();
            soc[z] = false;
            S.pop();
        }
        S.pop();
        soc[x] = false;
    }
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    
    int n, K; cin >> n >> K;
    fill(fi, fi + maxn, -1);
    fill(oc, oc + maxn, -1);
    fill(soc, soc + maxn, false);
    for (int j = 1; j <= n; j++) {
        cin >> a[j];
        if (fi[a[j]] < 0) fi[a[j]] = j;
    }
    for (int j = n; j >= 1; j--) {
        if (oc[a[j]] < 0) nx[j] = -1;
        else nx[j] = oc[a[j]];
        oc[a[j]] = j;
    }
    
    int p = 1;

    for (int j = 1; j <= n; ) {
        // cout << j << ", " << p << endl;
        if (nx[j] < 0) {
            p++; g[j] = fi[a[j]] + 1;
        } else {
            g[j] = nx[j] + 1;
        }
        j = g[j];
    }
    
    // cout << p << " ? p " << endl;
    K %= p;

    if (K == 0) {
        cout << endl; return 0;
    }
    K--;
    int j = 1;
    while (K > 0) {
        // cout << j << " --> " << K << endl;
        if (nx[j] < 0) {
            K--; j =  fi[a[j]] + 1;
        } else {
            j = nx[j] + 1;
        }
        if (K == 0) break;
        if (j > n) { j = 1; K--; }
    }
    // cout << " ?? " << j << endl;
    for (int k = j; k <= n; k++) {
        tpu(a[k]);
    }
    
    ans.clear();
    while (!S.empty()) { int z = S.top(); ans.pb(z); S.pop(); }
    reverse(all(ans));
    for (int e : ans) {
        cout << e << " ";
    }
    cout << endl;
}


Measured memory_bytes: 31012