#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;

    while(T--){
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for(int &x : a) cin >> x;

        vector<int> ans;
        bool ok = false;

        for(int mask = 0; mask < (1 << n); mask++){
            

            vector<int> b;
            vector<bool> used(26);

            for(int i = 0; i < n; i++){
                if(mask >> i & 1){
                    b.push_back(a[i]);
                    used[a[i]] = true;
                }
            }

            bool good = true;
            for(int i = 1; i <= k; i++){
                if(!used[i]){
                    good = false;
                    break;
                }
            }

            if(!good) continue;

            if(!ok || b < ans){
                ans = b;
                ok = true;
            }
        }

        for(int x : ans) cout << x << ' ';
        cout << '\n';
    }

    return 0;
}