#include <bits/stdc++.h>
using namespace std;
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;
  for (long long i = 0; i < k; ++i) {
    if (a[i] < b[n - 1 - i]) {
      s += b[n - 1 - i];
    } else {
      s += a[i];
    }
  }
  for (long long i = k; i < n; ++i) {
    s += a[i];
  }
  cout << s << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
