#include <bits/stdc++.h>
using namespace std;
long long powmod(long long base, long long exp, long long MOD) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return (res % MOD);
}
long long mpow(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return (res);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long int INF = 1 << 29;
const long long int maxn = 1e7;
const long long int mod = 1e9 + 7;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T... args) {
  ((cout << args << " "), ...);
}
signed main() {
  long long int t;
  read(t);
  while (t--) {
    long long int n;
    long long int m;
    long long int odd_p = 0;
    long long int even_p = 0;
    read(n);
    long long int p;
    for (long long int i = 0; i < n; ++i) {
      read(p);
      if (p % 2 != 0)
        odd_p++;
      else
        even_p++;
    }
    long long int odd_q = 0;
    long long int even_q = 0;
    read(m);
    for (long long int i = 0; i < m; ++i) {
      read(p);
      if (p % 2 != 0)
        odd_q++;
      else
        even_q++;
    }
    cout << even_p * even_q + odd_q * odd_p << "\n";
  }
  return 0;
}
