#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    vector<long long int> a, b;
    for (int i = 0, temp; i < n; i++) {
      cin >> temp;
      a.emplace_back(temp);
    }
    for (int i = 0, temp; i < n; i++) {
      cin >> temp;
      b.emplace_back(temp);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<long long int>());
    for (int i = 0; i < m; i++) {
      if (b[i] > a[i]) swap(a[i], b[i]);
    }
    long long int total = 0;
    for (int i = 0; i < n; i++) total += a[i];
    cout << total << endl;
  }
  return 0;
}
