#include <bits/stdc++.h>
#pragma GCC optimization("unroll-loops")
#pragma GCC optimization("O2")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, ans = 0;
    cin >> n >> k;
    int a[n], b[n];
    for (int i = 0; i < n; i += 1) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i += 1) {
      cin >> b[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    vector<int> v;
    for (int i = k; i < n; i += 1) {
      ans += a[i];
    }
    for (int i = 0; i < n; i += 1) {
      v.push_back(b[i]);
    }
    for (int i = 0; i < k; i += 1) {
      v.push_back(a[i]);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < k; i += 1) {
      ans += v[i];
    }
    cout << ans << endl;
  }
}
