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