#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;
const int maxm = 2e6 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
int n, m;
long long a[maxn], b[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    long long ans = 0;
    int x = 0, y = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      if (a[i] & 1)
        x++;
      else
        y++;
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%lld", &b[i]);
      if (b[i] & 1)
        ans += x;
      else
        ans += y;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
