#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int *a = new int[n];
    int *b = new int[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, greater<int>());
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (i < k) {
        ans += max(a[i], b[i]);
      } else {
        ans += a[i];
      }
    }
    cout << ans << '\n';
    continue;
  }
}
