#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } template T binarySearch(T ok, T ng, const F &f) { while (abs(ok - ng) > 1) { T mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } return ok; } void solve() { int n, m, k; cin >> n >> m >> k; long long p; cin >> p; vectort(n); rep(i, n)cin >> t[i]; vectorc(n); rep(i, n)cin >> c[i], c[i]--; vector col(k, vector()); vectorb(m); rep(i, m)cin >> b[i]; vectord(m); rep(i, m)cin >> d[i], d[i]--; rep(i, n) col[d[i]].push_back(b[i]); rep(i, k)sort(all(col[i])); auto sb = b; sort(all(sb)); vectors(k); rep(i, k)cin >> s[i]; // 価格がtarget以下の個数がp以下 auto f = [&](const long long target)->bool { long long cnt = 0; rep(i, n) { int tmp = 0; // all tmp += upper_bound(all(sb), target - t[i]) - sb.begin(); // same coler tmp -= upper_bound(all(col[c[i]]), target - t[i]) - col[c[i]].begin(); // same coler2 tmp += upper_bound(all(col[c[i]]), target - t[i] + s[c[i]]) - col[c[i]].begin(); cnt += tmp; } return cnt <= p - 1; }; auto pri = binarySearch(0, 2 * INF + 10, f) + 1; // cout << "p " << pri << endl; // col,val,idx mapmp; // val,col map>mp2; rep(i, m) { mp[{d[i], b[i]}] = i; mp2[b[i]].insert(d[i]); } rep(i, n) { { // not same int x = pri - t[i]; for (auto e : mp2[x]) { if (e == c[i])continue; auto ans2 = mp[{e, x}]; cout << i + 1 << " " << ans2 + 1 << endl; return; } } { // same int x = pri - t[i] + s[c[i]]; if (mp.count({ c[i],x })) { cout << i + 1 << " " << mp[{c[i], x}] + 1 << endl; return; } } } cout << "NG" << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int q; cin >> q; while (q--)solve(); return 0; }