#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const long long sz = 1e5 + 20;
void solve() {
  long long x;
  long long n;
  cin >> n;
  long long a = 0, b = 0, c = 0, d = 0;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    if (x & 1)
      a++;
    else
      b++;
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x;
    if (x & 1)
      c++;
    else
      d++;
  }
  cout << a * c + b * d << endl;
  return;
}
int32_t main() {
  clock_t st = clock();
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  clog << (long double)((clock() - st) / CLOCKS_PER_SEC) << endl;
  return 0;
}
