#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int b[k];
    for (int i = 0; i < k; i++) {
      cin >> b[i];
    }
    sort(a, a + n, greater<long long int>());
    sort(b, b + k);
    long long int sum = 0;
    int ind = k - 1;
    for (int i = 0; i < k; i++) {
      if (b[i] != 1) {
        ind = ind + b[i] - 1;
        sum += a[ind] + a[i];
      } else {
        sum += 2 * a[i];
      }
    }
    cout << sum << endl;
  }
}
