#include <bits/stdc++.h>
using namespace std;
long long int b_s(long long int a[], long long int l, long long int r,
                  long long int result) {
  long long int m;
  while (r >= l) {
    m = l + (r - l) / 2;
    if (a[m] == result)
      return m;
    else if (a[m] > result)
      r = m - 1;
    else
      l = m + 1;
  }
  return -1;
}
void solve() {
  long long int i, n, k, s = 0;
  cin >> n >> k;
  long long int a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  for (i = 0; i < n; i++) cin >> b[i];
  sort(a, a + n);
  sort(b, b + n);
  for (i = 0; i < k; i++) {
    if (a[i] < b[n - 1 - i])
      s = s - a[i] + b[n - 1 - i];
    else
      break;
  }
  cout << s << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
