#include <bits/stdc++.h>
using namespace std;
int main() {
  int col = 0;
  cin >> col;
  vector<int> ans(col);
  for (int j = 0; j < col; j++) {
    int a = 0, b = 0;
    cin >> a >> b;
    vector<int> v1(a);
    vector<int> v2(a);
    for (int i = 0; i < a; i++) {
      cin >> v1[i];
    }
    sort(v1.begin(), v1.end());
    for (int i = 0; i < a; i++) {
      cin >> v2[i];
    }
    sort(v2.begin(), v2.end());
    int k = 0;
    int sum = 0;
    if (v1[0] >= v2[a - 1]) {
      for (int i = 0; i < a; i++) {
        sum += v1[i];
      }
    } else {
      for (int i = 0; i < b; i++) {
        if (v1[i] < v2[v2.size() - 1]) {
          v1[i] = v2[v2.size() - 1];
          v2.erase(v2.end() - 1);
        }
      }
      for (int i = 0; i < v1.size(); i++) {
        sum += v1[i];
      }
    }
    ans[j] = sum;
  }
  for (int i = 0; i < col; i++) {
    cout << ans[i] << endl;
  }
}
