#include <bits/stdc++.h>
using namespace std;
int main() {
  long long tc = 1ll;
  cin >> tc;
  while (tc--) {
    long long n;
    cin >> n;
    long long k;
    cin >> k;
    long long a[n];
    long long 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, greater<long long>());
    long long c = 0;
    long long j = 0;
    long long s = 0;
    for (long long i = 0; i < n; i++) {
      if (c >= k) {
      } else {
        for (long long J = j; J < n; J++) {
          if (b[J] > a[i]) {
            a[i] = b[J];
            j++;
            c++;
            break;
          }
        }
      }
      s += a[i];
    }
    cout << s << "\n";
  }
  return 0;
}
