#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e18;
const int MX = 100001;
const double epsilon = 1e-12;
const vector<vector<int> > ds = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
void run_case() {
  int n, k;
  cin >> n >> k;
  int va[n], vb[n];
  memset(va, 0, sizeof(va));
  memset(vb, 0, sizeof(vb));
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    va[i] = m;
    sum += m;
  }
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    vb[i] = m;
  }
  sort(va, va + n);
  sort(vb, vb + n);
  int is = 0;
  int ie = n - 1;
  while (k > 0) {
    if (vb[ie] > va[is]) {
      sum += vb[ie];
      sum -= va[is];
      ie--;
      is++;
      k--;
    } else {
      break;
    }
  }
  printf("%d\n", sum);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    run_case();
  }
  return 0;
}
