#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    int j = 0, k = n - 1;
    while (m--) {
      if (a[j] < b[k]) swap(a[j], b[k]);
      j++;
      k--;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) sum = sum + a[i];
    cout << sum << endl;
  }
}
