#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, c1 = 0, c2 = 0;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 == 0)
      c1++;
    else
      c2++;
  }
  long long m, c3 = 0, c4 = 0;
  cin >> m;
  long long b[m];
  for (long long i = 0; i < m; i++) {
    cin >> b[i];
    if (b[i] % 2 == 0)
      c3++;
    else
      c4++;
  }
  cout << (c1 * c3 + c2 * c4) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long test;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
