#include <bits/stdc++.h>
using namespace std;
void sort(int *p, int n) {
  int temp, flag;
  for (int round = 1; round < n; round++) {
    flag = 1;
    for (int i = 0; i < n - round; i++)
      if (p[i] > p[i + 1]) {
        temp = p[i];
        p[i] = p[i + 1];
        p[i + 1] = temp;
        flag = 0;
      }
    if (flag) break;
  }
}
int main() {
  int t, n, k, sum, temp, *a, *b;
  cin >> t;
  while (t--) {
    sum = 0;
    cin >> n >> k;
    a = new int[n];
    b = new int[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    sort(a, n);
    sort(b, n);
    for (int i = 0; i < k; i++) {
      if (a[i] < b[n - 1 - i]) {
        temp = a[i];
        a[i] = b[n - 1 - i];
        b[n - 1 - i] = temp;
      } else
        break;
    }
    for (int i = 0; i < n; i++) sum += a[i];
    cout << sum << endl;
    free(a);
    free(b);
  }
  return 0;
}
