#include <bits/stdc++.h>
using namespace std;
int main() {
  int test, i, k, j, sum1, sum, n, p;
  cin >> test;
  for (i = 0; i < test; i++) {
    cin >> n >> k;
    sum = 0;
    sum1 = 0;
    vector<int> v1, v2;
    for (j = 0; j < n; j++) {
      cin >> p;
      v1.push_back(p);
    }
    for (j = 0; j < n; j++) {
      cin >> p;
      v2.push_back(p);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    for (j = 0; j < k; j++) {
      if (v2[n - j - 1] > v1[j])
        sum1 = sum1 + v2[n - j - 1];
      else
        sum1 = sum1 + v1[j];
    }
    for (j = k; j < n; j++) sum = sum + v1[j];
    cout << sum + sum1 << endl;
  }
  return 0;
}
