#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e5 + 20;
const long long inf = 3e6 + 20;
const long long ninf = -1e9;
const long long mod = 1e9 + 7;
void solve() {
  long long n, k;
  cin >> n >> k;
  priority_queue<long long, vector<long long>, greater<long long>> p;
  priority_queue<long long> q;
  long long x, y;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    p.push(x);
  }
  for (long long i = 0; i < n; i++) {
    cin >> x;
    q.push(x);
  }
  for (long long i = 0; i < k; i++) {
    if (q.top() > p.top()) {
      x = q.top();
      y = p.top();
      q.pop();
      p.pop();
      q.push(y);
      p.push(x);
    }
  }
  long long sum = 0;
  while (!p.empty()) {
    sum += p.top();
    p.pop();
  }
  cout << sum << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  cin >> T;
  while (T--) solve();
  return 0;
}
