#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b, k, sum;
  priority_queue<int> max;
  priority_queue<int, vector<int>, greater<int>> min;
  for (int i = 0; i < n; i++) {
    cin >> a >> k;
    sum = 0;
    for (int j = 0; j < a; j++) {
      cin >> b;
      sum = sum + b;
      min.push(b);
    }
    for (int j = 0; j < a; j++) {
      cin >> b;
      max.push(b);
    }
    while (k > 0) {
      if (max.top() < min.top()) {
        break;
      } else {
        sum = sum + (max.top() - min.top());
        min.push(max.top());
        max.pop();
        max.push(min.top());
        min.pop();
      }
      k--;
    }
    cout << sum << "\n";
    while (max.size() != 0) max.pop();
    while (min.size() != 0) min.pop();
  }
  return 0;
}
