#include <bits/stdc++.h>
void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}
int max(int a, int b) { return (a > b) ? a : b; }
int main() {
  int t, n, k, a[1005], b[1005];
  scanf("%d", &t);
  while (t--) {
    int total = 0;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      total += a[i];
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (a[i] > a[j]) swap(&a[i], &a[j]);
        if (b[i] < b[j]) swap(&b[i], &b[j]);
      }
    }
    for (int i = 0; i < k; i++) {
      total -= a[i];
      total += max(a[i], b[i]);
    }
    printf("%d\n", total);
  }
}
