#include <bits/stdc++.h>
int main() {
  long long int t, n, i, m;
  scanf("%lld", &t);
  for (i = 1; i <= t; i = i + 1) {
    scanf("%lld", &n);
    long long int p[n], j, a = 0, b = 0, c = 0, d = 0;
    for (j = 0; j < n; j = j + 1) {
      scanf("%lld", &p[j]);
      if (p[j] % 2 == 0) {
        a = a + 1;
      } else {
        b = b + 1;
      }
    }
    scanf("%lld", &m);
    long long int q[m];
    for (j = 0; j < m; j = j + 1) {
      scanf("%lld", &q[j]);
      if (q[j] % 2 == 0) {
        c = c + 1;
      } else {
        d = d + 1;
      }
    }
    printf("%lld\n", (a * c) + (b * d));
  }
}
