#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
double PI = 3.1415926535897;
const int N = 2e5 + 5, M = 50, MOD = 1e9 + 7, inf = 0x3f3f3f3f;
int tc, n, k, sum, a[M], b[M];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  scanf("%d", &tc);
  while (tc--) {
    sum = 0;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    for (int i = 0; i < n; i++) scanf("%d", b + i);
    sort(a, a + n);
    sort(b, b + n);
    int sta = 0, enb = n - 1;
    for (int j = k; k > 0; k--) {
      if (a[sta] < b[enb]) swap(a[sta], b[enb]);
      sta++, enb--;
    }
    for (int i = 0; i < n; i++) sum += a[i];
    printf("%d\n", sum);
  }
  return 0;
}
