#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int a, b, i, c, d = 0, n, t, h = 0;
  cin >> t;
  while (t--) {
    vector<long long int> v, v2;
    d = 0;
    cin >> a >> b;
    n = a;
    while (n--) {
      long long int b;
      cin >> b;
      v.push_back(b);
    }
    n = a;
    while (n--) {
      long long int b;
      cin >> b;
      v2.push_back(b);
    }
    sort(v.begin(), v.end());
    sort(v2.begin(), v2.end());
    h = a - 1;
    b = min(a, b);
    for (int i = 0; i < b; i++) {
      if (v[i] < v2[h]) {
        swap(v[i], v2[h]);
        h--;
      } else
        break;
    }
    for (int i = 0; i < a; i++) d += v[i];
    cout << d << endl;
  }
  return 0;
}
