#include <bits/stdc++.h>
using namespace std;
bool comp(int x, int y) { return x > y; }
int main() {
  int t;
  cin >> t;
  for (int l = 0; l < t; l++) {
    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, comp);
    int sum = 0;
    int i;
    int flag = 0;
    for (i = 0; i < k; i++) {
      if (b[i] > a[i]) {
        sum += b[i];
      } else {
        flag = 1;
        break;
      }
    }
    int j;
    if (flag)
      j = i;
    else
      j = i;
    for (; j < n; j++) {
      sum += a[j];
    }
    cout << sum << endl;
  }
  return 0;
}
