#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    std::vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    if (n == 1) {
      if (k != 0)
        cout << max(a[0], b[0]) << endl;
      else
        cout << a[0] << endl;
      continue;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    long long sum = 0;
    long long s = n - k;
    for (int i = n - 1; i >= k; i--) sum += a[i];
    int j = n - 1;
    int gg = k - 1;
    for (int i = 0; i < k; i++) {
      if (a[gg] >= b[j]) {
        sum += a[gg];
        gg--;
      } else {
        sum += b[j];
        j--;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
