#include <bits/stdc++.h>
using namespace std;
long long int t, n, k, m, res;
priority_queue<long long int> a, b;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  for (int T = (1); T <= (t); T++) {
    cin >> n >> k;
    res = 0;
    while (!a.empty()) a.pop();
    while (!b.empty()) b.pop();
    for (int i = (1); i <= (n); i++) {
      cin >> m;
      res += m;
      a.push(-m);
    }
    for (int i = (1); i <= (n); i++) {
      cin >> m;
      b.push(m);
    }
    for (int i = (1); i <= (k); i++) {
      m = a.top() * -1;
      if (b.top() > m) {
        res += b.top() - m;
        b.pop();
        a.pop();
      } else
        break;
    }
    cout << res << "\n";
  }
}
