#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int32_t main() {
  fast();
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    priority_queue<long long> b;
    priority_queue<long long, vector<long long>, greater<long long>> a;
    long long d;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      cin >> d;
      a.push(d);
      sum += d;
    }
    for (long long i = 0; i < n; i++) {
      cin >> d;
      b.push(d);
    }
    for (long long i = 0; i < k; i++) {
      if (a.top() < b.top()) {
        long long a1 = a.top();
        long long b1 = b.top();
        a.pop();
        b.pop();
        b.push(a1);
        a.push(b1);
        sum = sum - a1 + b1;
      } else
        break;
    }
    cout << sum << endl;
  }
}
