#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;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZnIgZmlyc3QKI2RlZmluZSBzYyBzZWNvbmQKI2RlZmluZSBzeih4KSAoaW50KSB4LnNpemUoKQojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGFsbCh4KSB4LmJlZ2luKCksIHguZW5kKCkKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnN0cmluZyBwcmludEJpbihsbCBtKSB7IHN0cmluZyBhID0gIiI7IGZvcihpbnQgaT02MzsgaT49MDsgaS0tKSB7IGlmKG0gJiAoMTw8aSkpIHthICs9ICcxJzt9IGVsc2Uge2EgKz0gJzAnO30gfSByZXR1cm4gYTsgfQoKaW50IG1haW4oKSB7CiAgICBpbnQgdDsgY2luID4+IHQ7CiAgICBjaW4uaWdub3JlKCk7CiAgICBjaW4uY2xlYXIoKTsKICAgIHdoaWxlKHQtLSkgewogICAgICAgIHN0cmluZyB0b3Q7CiAgICAgICAgZ2V0bGluZShjaW4sIHRvdCk7CiAgICAgICAgc3RyaW5nc3RyZWFtIHNzKHRvdCk7CgogICAgICAgIHNldDxzdHJpbmc+IHN0OwogICAgICAgIHN0cmluZyBhdXg7CiAgICAgICAgd2hpbGUoc3MgPj4gYXV4KSBzdC5pbnNlcnQoYXV4KTsKCiAgICAgICAgaW50IGkgPSAwOwogICAgICAgIGZvcihhdXRvIGFpIDogc3QpewogICAgICAgICAgICBpZihpID4gMCkgY291dCA8PCAiICI7CiAgICAgICAgICAgIGNvdXQgPDwgYWk7CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9CiAgICAgICAgY291dCA8PCBlbmRsOwogICAgfQp9Cg==