#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, get;
    cin >> n >> k;
    vector<int> a, b;
    for (int i = 0; i < n; i++) {
      cin >> get;
      a.push_back(get);
    }
    for (int i = 0; i < n; i++) {
      cin >> get;
      b.push_back(get);
    }
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (i < k) {
        ans += max(a[i], b[i]);
      } else {
        ans += a[i];
      }
    }
    cout << ans << endl;
  }
}
