#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n], b[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);
    long long cnt = 0, sum = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] < b[i] && cnt < k) {
        sum += b[i];
        cnt++;
      } else {
        sum += a[i];
      }
    }
    cout << sum << endl;
  }
  return 0;
}
