#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n, greater<int>());
    int sum = 0, i;
    for (i = 0; i < k; i++) {
      if (a[i] < b[i])
        sum += b[i];
      else
        break;
    }
    for (; i < n; i++) {
      sum += a[i];
    }
    cout << sum << "\n";
  }
  return 0;
}
