#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, num;
    cin >> n >> k;
    vector<int> a, b;
    for (int i = 0; i < n; i++) {
      cin >> num;
      a.push_back(num);
    }
    for (int i = 0; i < n; i++) {
      cin >> num;
      b.push_back(num);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int i = 0;
    while (k-- && (b[n - i - 1] > a[i])) {
      swap(a[i], b[n - i - 1]);
      i += 1;
    }
    cout << accumulate(a.begin(), a.end(), 0) << "\n";
  }
}
