#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
//using Int = __int128;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    Int N, K;
    vector<Int> A;
    vector<Int> P;
    vector<vector<Int>> iA;

    void calcloop() {
        Int idx = 0;
        int S = 1; //周期
        while (idx < N) {
//            auto npt = upper_bound(all(iA[A[idx]]), idx);
            auto it = upper_bound(iA[A[idx]].begin(), iA[A[idx]].end(), idx);

            if (it == iA[A[idx]].end()) {
                S++;
                it = lower_bound(all(iA[A[idx]]), 0);
            }
//            if (upper_bound(all(iA[A[idx]]), idx) == iA[P[idx]].end()) {
//                S++;
//                npt = lower_bound(all(iA[A[idx]]), 0);
//            }
            int nidx = *it + 1;
            if (P[nidx - 1] != -1) break;
            P[nidx - 1] = S;
            idx = nidx;
        }
    }

    void solve() {
        cin >> N >> K;
        A.resize(N);
        P.resize(N, -1);
        iA.resize(200001);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            iA[A[i]].push_back(i);
        }
        calcloop();

        K %= P[N - 1];
        if (K == 0) {
            return;
        }

        Int sidx = 0;
        for (int i = 0; i < N; ++i) {
            if (P[i] == K) {
                sidx = i + 1;
            }
        }
        set<Int> st;
        stack<Int> ans;
        for (Int i = sidx; i < N; ++i) {
            if (ans.empty() || !st.count(A[i])) {
                ans.push(A[i]);
                st.insert(A[i]);
            } else {
                while (st.count(A[i])) {
                    Int top = ans.top();
                    st.erase(top);
                    ans.pop();
                }
            }
        }
        vector<Int> tapi;
        while (!ans.empty()) {
            tapi.push_back(ans.top());
            ans.pop();
        }
        reverse(all(tapi));
        for (auto e : tapi) {
            cout << e << " ";
        }
        cout << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

//    vector<Int> v = {0};
//    auto it = upper_bound(all(v), 0);



//    if (it == v.end()) {
//        cout << "no" << endl;
//    } else {
//        cout << *it << endl;
//    }

    Solve().solve();


    return 0;
}


Measured memory_bytes: 28276