#include using namespace std; #define tsolve int t; cin >> t; while (t--) solve #define all(x) ::begin(x), ::end(x) #define sz(x) (ll)::size(x) using ll = long long; using ld = long double; void solve() { int n, na, nb, nc; cin >> n >> na >> nb >> nc; vector a(n); for (ll& e : a) cin >> e; ll tot = accumulate(all(a), 0LL); sort(all(a), greater<>()); vector suf(n+1); for (int i=n-1; i>=0; i--) suf[i] = suf[i+1] + a[i]; int b[3] = {na, nb, nc}; sort(all(b)); vector> ans(3); vector sm(3); vector rest; for (ll x : a) { for (int i=0; i<4; i++) { if (i == 3) { rest.push_back(x); break; } if (ssize(ans[i]) < b[i] && sm[i] * 4 < tot && (sm[i] + x + suf[n-(b[i] - ssize(ans[i]) - 1)])*2 < tot) { ans[i].push_back(x), sm[i] += x; break; } } } // for (int i=0; i<3; i++) { // for (int e : ans[i]) cout << e << ' '; // cout << '\n'; // } for (ll x : rest) { if (ssize(ans[0]) < b[0]) ans[0].push_back(x), sm[0] += x; else if (ssize(ans[1]) < b[1]) ans[1].push_back(x), sm[1] += x; else ans[2].push_back(x), sm[2] += x; } // for (int i=0; i<3; i++) { // for (int e : ans[i]) cout << e << ' '; // cout << '\n'; // } for (int i=0; i<3; i++) { if (sm[i] * 2 >= tot || ssize(ans[i]) != b[i]) { cout << "NO\n"; return; } } cout << "YES\n"; for (auto s : {na, nb, nc}) { for (auto& e : ans) if (ssize(e) == s) { for (ll x : e) cout << x << ' '; cout << '\n'; e.clear(); break; } } } int main() { cin.tie(0)->sync_with_stdio(false); cout << setprecision(16); tsolve(); }