#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n], b[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  sort(a, a + n);
  sort(b, b + n);
  long long int id = n - 1;
  for (long long int i = 0; i < n; i++) {
    if (a[i] < b[id] && k) {
      long long int temp = b[id];
      b[id] = a[i];
      a[i] = temp;
      k--;
      id--;
    }
  }
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) sum += a[i];
  cout << sum;
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
}
