#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int p, q, ep = 0, op = 0, eq = 0, oq = 0;
    cin >> p;
    long long int arr[p];
    for (int i = 0; i < p; i++) {
      cin >> arr[i];
      if (arr[i] % 2 == 0)
        ep++;
      else
        op++;
    }
    cin >> q;
    long long int arr2[q];
    for (int i = 0; i < q; i++) {
      cin >> arr2[i];
      if (arr2[i] % 2 == 0)
        eq++;
      else
        oq++;
    }
    long long int x;
    x = (ep * eq) + (op * oq);
    cout << x << endl;
  }
}
