#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;

#define int ll
#define pb push_back
#define pf push_front
#define in insert
#define f first
#define s second

mt19937_64 rnd;

signed main(){
  int t;
  cin >> t;
  while(t--){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), x(m);
    for(int &now : a) cin >> now;
    for(int &now : x) cin >> now;
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
      if(a[i] < x[0]){
        a[i] = x[0] - a[i];
        m--;
      }
      if(!m) break;
    }
    if(m % 2){
      sort(a.begin(), a.end());
      a[0] = x[0] - a[0];
    }
    int res = 0;
    for(int i = 0; i < n; i++) res += a[i];
    cout << res << '\n';
  }
  return 0;
}