#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<vector<int>> v(2 * pow(10, 5) + 1);
    rep(i, n) {
        cin >> a[i];
        v[a[i]].push_back(i);
    }

    ll cycle = 1;
    ll place = 0;

    while (place != n) {
        int index;
        int start = a[place];
        rep(i, v[start].size()) {
            if (v[start][i] == place) {
                index = i;
            }
        }

        if (index == v[start].size() - 1) {
            place = v[start][0] + 1;
            cycle++;
        } else {
            place = v[start][index + 1] + 1;
        }
    }

    ll num = k % cycle;
    if (num == 0) {
        cout << endl;
        return 0;
    }

    cycle = 1, place = 0;
    while (true) {
        int index;
        int start = a[place];
        rep(i, v[start].size()) {
            if (v[start][i] == place) {
                index = i;
            }
        }

        if (index == v[start].size() - 1) {
            if (cycle == num) {
                break;
            }
            place = v[start][0] + 1;
            cycle++;
        } else {
            place = v[start][index + 1] + 1;
        }
    }

    vector<ll> ans;
    copy(a.begin() + place, a.end(), back_inserter(ans));

    vector<ll> out;
    vector<vector<int>> v_out(2 * (pow(10, 5)));

    rep(i, ans.size()) { v_out[ans[i]].push_back(i); }

    place = 0;
    while (place != ans.size()) {
        int index;
        int start = ans[place];
        rep(i, v_out[start].size()) {
            if (v_out[start][i] == place) {
                index = i;
            }
        }

        if (index == v_out[start].size() - 1) {
            out.push_back(ans[place]);
            place++;
        } else {
            place = v_out[start][index + 1] + 1;
        }
    }

    rep(i, out.size()) { cout << out[i] << " "; }
    cout << endl;

    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 28276