#include <bits/stdc++.h>
using namespace std;
#define ms(s,n) memset(s,n,sizeof(s))
#define all(a) a.begin(),a.end()
#define present(t, x) (t.find(x) != t.end())
#define sz(a) int((a).size())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
void FileIO(){
freopen("input.txt","r", stdin);
freopen("output.txt","w",stdout);
}
int n,m,k;
void inp(){
cin>>n>>m>>k;
ll a[n],b[m],c[k];
FOR(i,0,n) cin>>a[i];
FOR(i,0,m) cin>>b[i];
FOR(i,0,k) cin>>c[i];
int i=0,j=0,l=0;
vector<ll> res;
while(i<n && j<m && l<k){
if(a[i]==b[j] && b[j]==c[l]){
res.pb(a[i]);
++i;++j;++l;
}
else if(a[i]<=b[j] && a[i]<=c[l]){
++i;
}
else if(b[j]<=a[i] && b[j]<=c[l]){
++j;
}
else
++l;
}
if(sz(res)==0){
cout<<"-1\n";
return;
}
for(ll x : res)
cout<<x<<" ";
cout<<"\n";
}
int main(){
//FileIO();
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;cin>>t;
while(t--){
inp();
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIG1zKHMsbikgbWVtc2V0KHMsbixzaXplb2YocykpCiNkZWZpbmUgYWxsKGEpIGEuYmVnaW4oKSxhLmVuZCgpCiNkZWZpbmUgcHJlc2VudCh0LCB4KSAodC5maW5kKHgpICE9IHQuZW5kKCkpCiNkZWZpbmUgc3ooYSkgaW50K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mJiBsPGspewoJCWlmKGFbaV09PWJbal0gJiYgYltqXT09Y1tsXSl7CgkJCXJlcy5wYihhW2ldKTsKCQkJKytpOysrajsrK2w7CgkJfQoJCWVsc2UgaWYoYVtpXTw9YltqXSAmJiBhW2ldPD1jW2xdKXsKCQkJKytpOwoJCX0KCQllbHNlIGlmKGJbal08PWFbaV0gJiYgYltqXTw9Y1tsXSl7CgkJCSsrajsKCQl9CgkJZWxzZQoJCQkrK2w7Cgl9CglpZihzeihyZXMpPT0wKXsKCQljb3V0PDwiLTFcbiI7CgkJcmV0dXJuOwoJfQoJZm9yKGxsIHggOiByZXMpCgkJY291dDw8eDw8IiAiOwoJY291dDw8IlxuIjsKfQoKaW50IG1haW4oKXsKCS8vRmlsZUlPKCk7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKG51bGxwdHIpOwoJaW50IHQ7Y2luPj50OwoJd2hpbGUodC0tKXsKCQlpbnAoKTsKCX0KfQ==
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
^
Main.java:4: error: illegal character: '#'
#define ms(s,n) memset(s,n,sizeof(s))
^
Main.java:4: error: class, interface, or enum expected
#define ms(s,n) memset(s,n,sizeof(s))
^
Main.java:5: error: illegal character: '#'
#define all(a) a.begin(),a.end()
^
Main.java:6: error: illegal character: '#'
#define present(t, x) (t.find(x) != t.end())
^
Main.java:7: error: illegal character: '#'
#define sz(a) int((a).size())
^
Main.java:8: error: illegal character: '#'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
^
Main.java:8: error: class, interface, or enum expected
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
^
Main.java:8: error: class, interface, or enum expected
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
^
Main.java:9: error: illegal character: '#'
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
^
Main.java:9: error: class, interface, or enum expected
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
^
Main.java:9: error: class, interface, or enum expected
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
^
Main.java:10: error: illegal character: '#'
#define pb push_back
^
Main.java:11: error: illegal character: '#'
#define pf push_front
^
Main.java:12: error: illegal character: '#'
#define fi first
^
Main.java:13: error: illegal character: '#'
#define se second
^
Main.java:14: error: illegal character: '#'
#define mp make_pair
^
Main.java:17: error: class, interface, or enum expected
typedef unsigned long long ull;
^
Main.java:18: error: class, interface, or enum expected
typedef long double ld;
^
Main.java:19: error: class, interface, or enum expected
typedef pair<int,int> pi;
^
Main.java:20: error: class, interface, or enum expected
typedef vector<int> vi;
^
Main.java:21: error: class, interface, or enum expected
typedef vector<pi> vii;
^
Main.java:23: error: class, interface, or enum expected
const int MOD = (int) 1e9+7;
^
Main.java:24: error: class, interface, or enum expected
const int INF = (int) 1e9+1;
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:25: error: class, interface, or enum expected
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
^
Main.java:26: error: class, interface, or enum expected
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
^
Main.java:31: error: class, interface, or enum expected
freopen("output.txt","w",stdout);
^
Main.java:32: error: class, interface, or enum expected
}
^
Main.java:36: error: class, interface, or enum expected
void inp(){
^
Main.java:38: error: class, interface, or enum expected
ll a[n],b[m],c[k];
^
Main.java:39: error: class, interface, or enum expected
FOR(i,0,n) cin>>a[i];
^
Main.java:40: error: class, interface, or enum expected
FOR(i,0,m) cin>>b[i];
^
Main.java:41: error: class, interface, or enum expected
FOR(i,0,k) cin>>c[i];
^
Main.java:42: error: class, interface, or enum expected
int i=0,j=0,l=0;
^
Main.java:43: error: class, interface, or enum expected
vector<ll> res;
^
Main.java:44: error: class, interface, or enum expected
while(i<n && j<m && l<k){
^
Main.java:47: error: class, interface, or enum expected
++i;++j;++l;
^
Main.java:47: error: class, interface, or enum expected
++i;++j;++l;
^
Main.java:47: error: class, interface, or enum expected
++i;++j;++l;
^
Main.java:48: error: class, interface, or enum expected
}
^
Main.java:51: error: class, interface, or enum expected
}
^
Main.java:54: error: class, interface, or enum expected
}
^
Main.java:57: error: class, interface, or enum expected
}
^
Main.java:60: error: class, interface, or enum expected
return;
^
Main.java:61: error: class, interface, or enum expected
}
^
Main.java:64: error: class, interface, or enum expected
cout<<"\n";
^
Main.java:65: error: class, interface, or enum expected
}
^
Main.java:70: error: class, interface, or enum expected
cin.tie(nullptr);
^
Main.java:71: error: class, interface, or enum expected
int t;cin>>t;
^
Main.java:71: error: class, interface, or enum expected
int t;cin>>t;
^
Main.java:72: error: class, interface, or enum expected
while(t--){
^
Main.java:74: error: class, interface, or enum expected
}
^
58 errors