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