#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int arr[a], arr1[a];
    for (long long int i = 0; i < a; i++) {
      cin >> arr[i];
    }
    for (long long int i = 0; i < a; i++) {
      cin >> arr1[i];
    }
    sort(arr, arr + a);
    sort(arr1, arr1 + a, greater<int>());
    for (long long int i = 0; i < a; i++) {
      if (b == 0) {
        break;
      } else {
        if (arr[i] < arr1[i]) {
          swap(arr[i], arr1[i]);
          b--;
        }
      }
    }
    long long int sum = 0;
    for (long long int i = 0; i < a; i++) {
      sum += arr[i];
    }
    cout << sum << endl;
  }
}
