#include <bits/stdc++.h>
using namespace std;
bool compareDESC(int a, int b) { return a >= b; }
void solve() {
  long long n, k, sum = 0;
  cin >> n >> k;
  vector<int> 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.rbegin(), b.rend());
  for (long long i = 0; i < n; i++) {
    if (k > i) {
      sum += max(a[i], b[i]);
    } else {
      sum += a[i];
    }
  }
  cout << sum << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
