#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k, sum = 0;
    cin >> n >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < a.size(); i++) {
      cin >> a[i];
    }
    for (int i = 0; i < b.size(); i++) {
      cin >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    for (int i = 0, j = n - 1; k > 0; i++, j--, k--) {
      if (a[i] <= b[j]) {
        int temp = a[i];
        a[i] = b[j];
        b[j] = temp;
      }
    }
    for (auto x : a) {
      sum += x;
    }
    cout << sum << "\n";
  }
  return 0;
}
