#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<>()); int b[3] = {na, nb, nc}; sort(all(b)); vector> ans(3); vector sm(3); for (ll x : a) { if (ssize(ans[0]) < b[0] && (sm[0] + x) * 2 < tot) ans[0].push_back(x), sm[0] += x; else if (ssize(ans[1]) < b[1] && (sm[1] + x) * 2 < tot) ans[1].push_back(x), sm[1] += x; else ans[2].push_back(x), sm[2] += x; } if (sm[2] * 2 >= tot || ssize(ans[0]) != b[0] || ssize(ans[1]) != b[1] || ssize(ans[2]) != b[2]) { 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(); }