#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 pref(n+1); for (int i=0; i> ans(3); vector used(n); int l; bool flag = false; ll sma = a[0] + psum(n-b[0]+1, n); ll rest = pref[n] - sma; if (sma * 2 >= tot) goto NO; for (l=1; l<=1+b[1]; l++) { ll idk = psum(l, l+b[1]); if (idk*2 < tot && (rest-idk)*2 < tot) { flag = true; break; } } if (flag) { ans[0].push_back(a[0]); used[0] = true; for (int i=1; i 0) ans[1].push_back(a[i]), b[1]--; else ans[2].push_back(a[i]); } goto YES; } goto NO; YES: 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; } } return; NO: cout << "NO\n"; return; } int main() { cin.tie(0)->sync_with_stdio(false); cout << setprecision(16); tsolve(); }