#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    int ptr1 = n - 1, ptr2 = n - 1;
    long ans = 0;
    while (n) {
      if (a[ptr1] >= b[ptr2] || !k) {
        ans += a[ptr1];
        ptr1--;
      } else {
        ans += b[ptr2];
        ptr2--;
        k--;
      }
      n--;
    }
    cout << ans << "\n";
  }
  return 0;
}
