#pragma GCC optimize "O3" #include using namespace std; using LL=long long; #define FOR(i,l,r) for(int i=(l);i<=(r);++i) #define REP(i,n) FOR(i,0,(n)-1) #define ssize(x) int(x.size()) #ifdef DEBUG auto&operator<<(auto&o,pairp){return o<<"("<decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<sync_with_stdio(0); int tests; cin >> tests; REP (test, tests) { int n; vector nx(3, 0); cin >> n; REP (i, 3) cin >> nx[i]; vector> t; vector ori(n); LL sum = 0; REP (i, n) { int x; cin >> x; ori[i] = x; sum += x; t.emplace_back(x, i + 1); } vector> ans(3); bool ok = true; REP (i, 3) { sort(t.rbegin(), t.rend()); assert(n == ssize(t)); debug(i, t); vector suff(n + 1); for (int j = n - 1; j >= 0; --j) { suff[j] = t[j].first; suff[j] += suff[j + 1]; } debug(suff); int p = 0; LL lim = (sum - 1) / 2; debug(lim); vector odw(n); REP (j, nx[i]) { debug(j, p); while (p < n && !(lim >= t[p].first + suff[n - (nx[i] - j - 1)])) { ++p; } debug(p); if (p == n) { ok = false; break; } ans[i].emplace_back(t[p].second); lim -= t[p].first; odw[p] = 1; ++p; } if (!ok) break; vector> nt; REP (j, n) if (!odw[j]) nt.emplace_back(t[j]); t = nt; n = ssize(t); } if (ok) { debug(ans); vector odw(nx[0] + nx[1] + nx[2]); REP (i, 3) { assert(ssize(ans[i]) == nx[i]); LL sm = 0; REP (j, nx[i]) { sm += ori[ans[i][j] - 1]; assert(!odw[ans[i][j] - 1]); odw[ans[i][j] - 1] = 1; } assert(sm <= (sum - 1) / 2); } cout << "YES\n"; #ifndef LOCAL REP (i, 3) { REP (j, nx[i]) { if (j) cout << ' '; cout << ori[ans[i][j] - 1]; } cout << '\n'; } #endif } else { cout << "NO\n"; } } }