#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  short t;
  cin >> t;
  while (t--) {
    short n, k;
    cin >> n >> k;
    short a[n], b[n];
    for (short i = 0; i < n; i++) cin >> a[i];
    for (short i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    short i = 0;
    while (k-- && a[i] < b[n - i - 1]) {
      a[i] ^= b[n - i - 1];
      b[n - i - 1] ^= a[i];
      a[i] ^= b[n - i - 1];
      i++;
    }
    short s = 0;
    for (const short& value : a) s += value;
    cout << s << "\n";
  }
}
