#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, m, n, t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int a[n + 1], b[n + 1];
    k = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      k += a[i];
    }
    for (i = 0; i < n; i++) {
      cin >> b[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    i = 0, j = n - 1;
    while (m > 0 && i < n && j >= 0 && a[i] < b[j]) {
      k += b[j] - a[i];
      i++;
      j--;
      m--;
    }
    cout << k << endl;
  }
}
