#include <bits/stdc++.h>
using namespace std;
mt19937 prng(chrono::steady_clock::now().time_since_epoch().count());
void testCase(int caseno) {
  int n, k, a, b;
  cin >> n >> k;
  multiset<int> aa;
  multiset<int> bb;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    aa.insert(a);
  }
  for (int i = 0; i < n; i++) {
    cin >> b;
    bb.insert(b);
  }
  for (int i : aa) {
  }
  for (int i : bb) {
  }
  int it = 0;
  while (*(aa.begin()) < *(--bb.end()) && it < k) {
    it++;
    sum -= *(aa.begin());
    sum += *(--bb.end());
    aa.insert(*(--bb.end()));
    bb.insert(*(aa.begin()));
    auto ita = aa.begin();
    auto itb = --bb.end();
    aa.erase(ita);
    bb.erase(itb);
  }
  cout << sum << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    testCase(i + 1);
  }
  return 0;
}
