#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
const long long INF = 9e18;
const long long N = 998244353;
const double eps = 1e-9;
const auto start_time = std::chrono::high_resolution_clock::now();
void zark() {}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n), b(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  for (long long i = (0); i < (n); i++) cin >> b[i];
  sort((a).begin(), (a).end());
  sort((b).begin(), (b).end());
  long long s = 0;
  long long i = 0, j = n - 1, cnt = 0;
  while (cnt < k && i < n && j >= 0) {
    if (a[i] < b[j])
      s += b[j], cnt++, j--, i++;
    else
      break;
  }
  for (long long ii = i; ii < n; ii++) s += a[ii];
  cout << s << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  zark();
  return 0;
}
