#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
long long int dx_8[] = {-1, -1, -1, 0, 0, 1, 1, 1},
              dy_8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long int M = 1000000007;
long long int big_mod(long long int n, long long int p) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long int ret = big_mod(n, p / 2);
    return ((ret % M) * (ret % M)) % M;
  } else
    return ((n % M) * (big_mod(n, p - 1) % M)) % M;
}
long long int reminder(string s, long long int n) {
  long long int mod = 0;
  for (long long int i = 0; i < s.size(); i++) {
    long long int digit = (long long int)s[i] - '0';
    mod = mod * 10 + digit;
    mod = mod % n;
  }
  return mod;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, n, m, x, y;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int odd = 0, even = 0, o = 0, e = 0;
    while (n--) {
      cin >> x;
      (x & 1) ? odd++ : even++;
    }
    cin >> m;
    while (m--) {
      cin >> y;
      (y & 1) ? o++ : e++;
    }
    cout << odd * o + even * e << endl;
    cerr << "------\n";
  }
  return 0;
}
