intmain() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin >> t; while (t--) { int n, k, res = 0; cin >> n >> k; for (int i = n - 1; i >= 1; i--) { k -= i; if (k >= 0) res ++; elsebreak; } cout << n - res << '\n';if (k >= n - 1) { cout << 1 << "\n"; } else { cout << n << '\n'; }
voidsolve(){ int n, k; cin >> n >> k; map<int, int> mp1, mp2; for (int i = 1, x; i <= n * 2; i ++) { cin >> x; if (i <= n) mp1[x] ++; else mp2[x] ++; } vector<int> a, b; for (auto [x, y] : mp1) { if (y == 2) { a.push_back(x); a.push_back(x); if ((int)a.size() == k * 2) break; } } for (auto [x, y] : mp2) { if (y == 2) { b.push_back(x); b.push_back(x); if ((int)b.size() == k * 2) break; } } if ((int)a.size() < k * 2) { for (auto [x, y] : mp1) { if(y == 2) continue; a.push_back(x); b.push_back(x); if ((int)a.size() == k * 2) break; } } for (auto i : a) cout << i << ' '; cout << endl; for (auto i : b) cout << i << ' '; cout << endl; } intmain(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int t; cin >> t; while (t--) { solve(); } }