#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int k = 0; k < t; k++) {
    int n, m;
    cin >> n >> m;
    int b[n];
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    sort(b, b + n);
    int c[n];
    for (int i = 0; i < n; i++) {
      cin >> c[i];
    }
    sort(c, c + n);
    int x = 0;
    int tmp;
    for (int i = 0; i < n; i++) {
      if (m == 0) break;
      if (b[i] < c[n - i - 1]) {
        tmp = b[i];
        b[i] = c[n - i - 1];
        c[n - i - 1] = tmp;
        m--;
      } else
        break;
    }
    for (int i = 0; i < n; i++) {
      x += b[i];
    }
    cout << x << endl;
  }
  return 0;
}
