#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const long long MOD = 1e9 + 7;
const long long INF = 0x3f3f3f3f;
long long read() {
  long long x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - 48;
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return x * f;
}
int N, M;
void init() {}
void solve() {
  long long a[2], b[2];
  int now;
  scanf("%d", &N);
  a[0] = a[1] = b[0] = b[1] = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &now);
    a[now & 1]++;
  }
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &now);
    b[now & 1]++;
  }
  printf("%lld\n", a[0] * b[0] + a[1] * b[1]);
}
int main() {
  int T;
  T = 1;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
  return 0;
}
