#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    priority_queue<int> b;
    priority_queue<int, vector<int>, greater<int> > a;
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      a.push(x);
      ans += x;
    }
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      b.push(x);
    }
    while (k--) {
      int c = b.top(), d = a.top();
      if (c > d) {
        ans += (c - d);
        a.pop();
        b.pop();
      } else
        break;
    }
    cout << ans << endl;
  }
  return 0;
}
