#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9 + 7;
const int maxn = 300005;
const int logn = 20;
int a[maxn], b[maxn], n, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= (n); i++) cin >> a[i];
    for (int i = 1; i <= (n); i++) cin >> b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1, greater<int>());
    int i = 1;
    while (k-- && b[i] > a[i]) {
      swap(a[i], b[i]);
      ++i;
    }
    long long s = 0LL;
    for (int i = 1; i <= (n); i++) s += a[i];
    cout << s << "\n";
  }
  return 0;
}
