#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
void solve() {
  long long int n, k;
  vector<long long int> va, vb;
  cin >> n >> k;
  for (long long int i = 1; i <= n; i++) {
    long long int a;
    cin >> a;
    va.push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    long long int a;
    cin >> a;
    vb.push_back(a);
  }
  sort(va.begin(), va.end());
  sort(vb.rbegin(), vb.rend());
  for (long long int i = 0; i < n; i++) {
    if (va[i] < vb[i] && k > 0) {
      swap(va[i], vb[i]);
      k--;
    }
  }
  long long int sum = 0;
  for (auto it : va) sum += it;
  cout << sum << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
