/* AGC036 B */

#include <bits/stdc++.h>

using namespace std;

#define ll long long

//#define TEST

signed main(){
    int n;
    ll k;
    cin >> n >> k;
    int* a = new int[n];
    for (int i = 0;i < n;++i)
        cin >> a[i];
    
    /* 数列aに登場する各要素について、登場するインデックスを管理 */
    map<int,vector<int>> v_i;
    for (int i = 0;i < n;++i){
        v_i[a[i]].push_back(i);
    }
    for (int i = 0;i < n;++i)
        v_i[a[i]].push_back((int)2e5+1); // 以下でlower_boundを使うため

    /* v_iの確認 */
#ifdef TEST
    cout << "---------v_i---------" << endl;
    for (int i = 0;i < n;++i){
        for (auto index : v_i[a[i]])
            cout << index << " ";
        cout << endl;
    }
#endif

    /* 
        次のような配列delを計算
            del[i].first : a[i]から始まったsがa[j]で全消しされるj 
            del[i].second : そのようなjまでに何回ループするか(0 or 1)
    */
    pair<int,int>* del = new pair<int,int>[n];
    for (int i = 0;i < n;++i){
        auto iter = lower_bound(v_i[a[i]].begin(),v_i[a[i]].end(),i + 1);
        if (*iter == (int)2e5 + 1)
            del[i].first = v_i[a[i]][0];
        else
            del[i].first = *iter;
        if (del[i].first > i)
            del[i].second = 0;
        else
            del[i].second = 1;
    }

    /* delの確認 */
#ifdef TEST
    cout << "---------del---------" << endl;
    for (int i = 0;i < n;++i)
        cout << "(" << del[i].first << "," <<
            del[i].second << ") ";
    cout << endl;
#endif 

    /* 
        次のような配列nextを計算
            next[i][j].first : 
                a[i]から始まったsが2^j回全消しされた後、a[l]が書かれるl
            next[i][j].second :
                a[l]が書かれる直前のループ回数
     */
    int dig = max(1,(int)(log(n * k / 2) / log(2)));
    pair<int,ll>** next = new pair<int,ll>*[n];
    for (int i = 0;i < n;++i)
        next[i] = new pair<int,ll>[dig];
    for (int i = 0;i < n;++i){
        next[i][0].first = (del[i].first + 1) % n;
        next[i][0].second = del[i].second + (del[i].first == n - 1 ? 1 : 0);
    }
    for (int j = 1;j < dig;++j){
        for (int i = 0;i < n;++i){
            int nx_ind = next[i][j - 1].first;
            ll nx_c = next[i][j - 1].second;
            next[i][j].first = next[nx_ind][j - 1].first;
            next[i][j].second = next[nx_ind][j - 1].second + nx_c;
        }
    }

    /* nextの確認 */
#ifdef TEST
    cout << "---------next--------" << endl;
    for (int i = 0;i < n;++i){
        for (int j = 0;j < dig;++j)
            cout << "(" << next[i][j].first << "," <<
                next[i][j].second << ") ";
        cout << endl;
    }
#endif

    /* 操作終了に十分近い全消しを求める */
    int index = 0; // 次に書き込むaのindex
    ll count = 0; // 現在の操作回数
    while (true){
        if (count == k - 1) break;
        if (k - count > next[index][dig - 1].second){
            count += next[index][dig - 1].second;
            index = next[index][dig - 1].first;
            continue;
        }
        int left = 0;
        int right = dig - 1;
        /* k - countを超えないものを二分探索で求める */
        while (right - left > 1){
            int mid = left + (right - left) / 2;
            if (k - count > next[index][mid].second)
                left = mid;
            else
                right = mid;
        }
        count += next[index][left].second;
        index = next[index][left].first;
        //bool f = false; // ループを抜けるかのフラグ
        //for (int j = dig - 1;j >= 0;--j){
        //    if ((k - count) > next[index][j].second){
        //        count += next[index][j].second;
        //        index = next[index][j].first;
        //        f = true;
        //        break;
        //    }
        //}
        //if (!f) break;
    }

    /* indexとcountの確認 */
#ifdef TEST
    cout << "---------index-------" << endl;
    cout << index << endl;
    cout << "---------count-------" << endl;
    cout << count << endl;
#endif

    /* 答えの計算 */
#ifdef TEST
    cout << "---------ans---------" << endl;
#endif
    do{
        if (next[index][0].second == 0 || (next[index][0].first == 0 && next[index][0].second == 1)){
            index = next[index][0].first;
        }
        else{
            cout << a[index] << " ";
            ++index;
            index %= n;
        }
    } while (index > 0);
    cout << endl;

    delete[] a,del;
    for (int i = 0;i < n;++i)
        delete[] next[i];
    delete[] next;
    return 0;
}

Measured memory_bytes: 205184