#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define sz(x) (int) x.size()
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;
string printBin(ll m) { string a = ""; for(int i=63; i>=0; i--) { if(m & (1<<i)) {a += '1';} else {a += '0';} } return a; }

int main() {
    int t; cin >> t;
    cin.ignore();
    cin.clear();
    while(t--) {
        string tot;
        getline(cin, tot);
        stringstream ss(tot);

        set<string> st;
        string aux;
        while(ss >> aux) st.insert(aux);

        int i = 0;
        for(auto ai : st){
            if(i > 0) cout << " ";
            cout << ai;
            i++;
        }
        cout << endl;
    }
}
