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