#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a;
    vector<int> b;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      a.push_back(x);
    }
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      b.push_back(x);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int sum = 0;
    int l1 = 0, l2 = b.size() - 1;
    int ct = n;
    for (int i = 0; i < k && ct != -1;) {
      if (b[l2] > a[l1]) {
        sum += b[l2];
        i++;
        ct--;
        l2--;
        l1++;
      } else
        break;
    }
    for (int i = l1; i < n; i++) sum += a[i];
    cout << sum << endl;
  }
  return 0;
}
