//const int N = 2e5+5, K = 61;
//__int128 jump_to[N][K],jump_cost[N][K];
//void _(){
//    ll n,k;
//    cin >> n >> k;
//    vl arr(n);
//    cin >> arr;
//    arr.insert(arr.end(),all(arr));
//    map<int,int> last;
//    for(int i = 2*n-1; i >= 0; --i){
//        if(i < n){
//            int p = last[arr[i]];
//            jump_to[i][0] = (p+1)%n;
//            jump_cost[i][0] = p+1-i;
//        }
//        last[arr[i]] = i;
//    }
//    bool ok = true;
//    for(int s = 1; s < K; ++s){
//        if(!ok)
//            break;
//        for(int i = 0; i < n; ++i){
//            jump_to[i][s] = jump_to[jump_to[i][s-1]][s-1];
//            jump_cost[i][s] = jump_cost[i][s-1] + jump_cost[jump_to[i][s-1]][s-1];
//
//        }
//    }
//    ll lim = n*k;
//    ll start = 0;
//    ll used = 0;
//    for(int i = K-1; i >= 0; --i){
//        if(jump_cost[start][i]+used < lim){
//            used += jump_cost[start][i];
//            start = jump_to[start][i];
//        }
//    }
//    vi seen(N);
//    vi ans;
//    while(used < lim){
//        int x = arr[used%n];
//        if(seen[x] == 0){
//            ans.pb(x);
//            seen[x] = 1;
//        }
//        else{
//            while(seen[x] >= 1){
//                seen[ans.back()]--;
//                ans.pop_back();
//            }
//        }
//        ++used;
//    }
//    print(ans);
//}
//
#include <map>
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 ostream& print(T b, T e, string sep = " ", ostream& stream = cout){
    for(T it = b; it != e; ++it){
        stream << *it;
        if(it + 1 != e)
            stream << sep;
    }
    return stream;
}
T1 void print(vector<T> arr, string sep = " "){
    if(arr.empty()){
        return;
    }
    print(arr.begin(), arr.end(), sep);
    cout << '\n';
}
const int N = 2e5+5, K = 61;
__int128 jump_to[N][K],jump_cost[N][K];
void _(){
    ll n,k;
    cin >> n >> k;
    vl arr(n);
    cin >> arr;
    arr.insert(arr.end(),all(arr));
    map<int,int> last;
    for(int i = 2*n-1; i >= 0; --i){
        if(i < n){
            int p = last[arr[i]];
            jump_to[i][0] = (p+1)%n;
            jump_cost[i][0] = p+1-i;
        }
        last[arr[i]] = i;
    }
    bool ok = true;
    for(int s = 1; s < K; ++s){
        if(!ok)
            break;
        for(int i = 0; i < n; ++i){
            jump_to[i][s] = jump_to[jump_to[i][s-1]][s-1];
            jump_cost[i][s] = jump_cost[i][s-1] + jump_cost[jump_to[i][s-1]][s-1];
        }
    }
    ll lim = n*k;
    ll start = 0;
    ll used = 0;
    for(int i = K-1; i >= 0; --i){
        if(jump_cost[start][i]+used < lim){
            used += jump_cost[start][i];
            start = jump_to[start][i];
        }
    }
    vi seen(N);
    vi ans;
    while(used < lim){
        int x = arr[used%n];
        if(seen[x] == 0){
            ans.pb(x);
            seen[x] = 1;
        }
        else{
            while(seen[x] >= 1){
                seen[ans.back()]--;
                ans.pop_back();
            }
        }
        ++used;
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 397924