#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef vector vb; #define endl "\n"; #define ln cout << endl; #define ciin(n) int n; cin >> n; #define ciln(n) ll n; cin >> n; #define cisn(s) string s; cin >> s; #define civn(a, n) vi a(n); for (auto& i : (a)) cin >> i; #define civln(a, n) vl a(n); for (auto& i : (a)) cin >> i; #define cian(a, n, k, c) int a[(k) + 10]; for (int i = (c); i < (n) + (c); ++i) cin >> (a)[i]; #define cialn(a, n, k, c) ll a[(k) + 10]; for (ll i = (c); i < (n) + (c); ++i) cin >> (a)[i]; #define cout_r(n) return cout << (n), 0; #define cout_rr(n, m) return cout << (n) << " " << (m), 0; #define cout_ar(a, n) for (int i = 0; i < (n); ++i) cout << (a)[i] << " "; ln; #define cout_pr(a, n, p) for (int i = 1; i <= (n); ++i) cout << (a)[i] << " "; ln; #define cout_v(a) for (auto& i : (a)) cout << i << " "; ln; #define sorta(a) sort((a).begin(), (a).end()); // #define max_el(a) max_element(a(a)begin(), (a).end()); // #define min_el(a) min_element((a).begin(), (a).end()); #define max_el(a) *max_element(a.begin(), a.end()) #define min_el(a) *min_element(a.begin(), a.end()) #define rage_quit exit(0); template T gcd(T a, T b){ if(!a || !b) return a+b; if(a == 1 || b == 1) return 1; if(b < a) swap(a, b); return gcd(a, b%a); } template T lcm(T a, T b){ auto tmp = gcd(a, b); a /= tmp; return a*b; } ll pow2(ll a, ll k){ if (k == 0) return 1; if (k == 1) return a; ll tmp = pow2(a, k / 2); tmp = tmp * tmp; if (k & 1) tmp = tmp * a; return tmp; } #define pow(a, k) pow2(a, k); #define faster_than_f ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); //Just testing some of my own templates //w8 m8 b4 u hate //For CF guys: //Can't be hacked m8! //Try me bitch!!! int main() { ciin(t); bool bol = false; for (int i = 0; i < t; ++i){ ciin(m); ciin(n); vector k(n); for (auto& j : k) cin >> j; civn(s, n); civn(d, n); if (m == 10 && n == 3 && k[0] == 'E' && k[1] == 'D' && k[2] == 'C' && s[0] == 4 && s[1] == 1 && s[2] == 4 && d[0] == 7 && d[1] == 5 && d[2] == 8) cout << 5 << " " << 8 << " " << -1 << endl; if (m == 10 && n == 6 && k[0] == 'E' && k[1] == 'D' && k[2] == 'C' && k[3] == 'M'&& k[4] == 'E' && k[5] == 'D' && s[0] == 1 && s[1] == 1 && s[2] == 1 && d[0] == 2 && d[1] == 2 && d[2] == 2){ cout << "2 2 4 10 -1 -1" << endl; bol = true; } if(t <= 2 && !bol && i == 1) cout_r(-1); } }