#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int arr[n], brr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n, greater<int>());
    for (int j = 0; j < n; j++) {
      cin >> brr[j];
    }
    sort(brr, brr + n, greater<int>());
    int ans = 0;
    int i = 0, j = 0;
    int cnt = n;
    while (cnt--) {
      if (arr[i] >= brr[j])
        ans += arr[i], i += 1;
      else if (k > 0)
        ans += brr[j], j += 1, k -= 1;
      else
        ans += arr[i], i += 1;
    }
    cout << ans << endl;
  }
  return 0;
}
