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