#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[100010];
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return f * x;
}
signed main() {
  long long t = read();
  while (t--) {
    long long n = read(), cnt = 0, ans = 0;
    for (register long long i = 1; i <= n; ++i) {
      a[i] = read();
      if (a[i] & 1) cnt++;
    }
    long long m = read();
    for (register long long i = 1; i <= m; ++i) {
      b[i] = read();
      if (b[i] & 1)
        ans += cnt;
      else
        ans += n - cnt;
    }
    cout << ans << endl;
  }
  return 0;
}
