#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, unsigned long long int y,
                    long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    long long int ao = 0, ae = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 == 0) {
        ae++;
      } else
        ao++;
    }
    long long int m;
    cin >> m;
    long long int b[m];
    long long int bo = 0, be = 0;
    for (long long int i = 0; i < m; i++) {
      cin >> b[i];
      if (b[i] % 2 == 0) {
        be++;
      } else
        bo++;
    }
    long long int ans = 0;
    ans += be * ae;
    ans += ao * bo;
    cout << ans << endl;
  }
  return 0;
}
