#include <bits/stdc++.h>
using namespace std;
map<long long, long long>::iterator itr;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long t;
  cin >> t;
  while (t--) {
    long long num, k;
    cin >> num >> k;
    vector<long long> v;
    vector<long long> v1;
    for (long long i = 0; i < num; i++) {
      long long x;
      cin >> x;
      v.push_back(x);
    }
    for (long long i = 0; i < num; i++) {
      long long x;
      cin >> x;
      v1.push_back(x);
    }
    sort(v.begin(), v.end());
    sort(v1.begin(), v1.end(), greater<long long>());
    long long sum = 0;
    for (long long i = 0; i < k; i++) {
      if (v1[i] > v[i])
        sum += v1[i];
      else
        sum += v[i];
    }
    for (long long i = k; i < num; i++) {
      sum += v[i];
    }
    cout << sum << endl;
  }
}
