#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  ;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  ;
  long long m;
  cin >> m;
  ;
  long long b[m];
  for (long long i = 0; i < m; i++) cin >> b[i];
  ;
  long long Aodd = 0, Bodd = 0, Aevn = 0, Bevn = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] & 1)
      Aodd++;
    else
      Aevn++;
  }
  for (long long i = 0; i < m; i++) {
    if (b[i] & 1)
      Bodd++;
    else
      Bevn++;
  }
  cout << ((Aodd * Bodd) + (Aevn * Bevn)) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  while (T--) solve();
  return 0;
}
