#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while ((t)--) {
    int n;
    cin >> n;
    int push[n];
    long long cep = 0;
    long long cop = 0;
    for (int i = (0); i < (n); i++) {
      cin >> push[i];
      if (push[i] % 2 == 0)
        cep++;
      else
        cop++;
    }
    int m;
    cin >> m;
    int q[m];
    long long ceq = 0;
    long long coq = 0;
    for (int i = (0); i < (m); i++) {
      cin >> q[i];
      if (q[i] % 2 == 0)
        ceq++;
      else
        coq++;
    }
    long long ans = cep * ceq + cop * coq;
    cout << ans << "\n";
  }
}
