#include <bits/stdc++.h>
using namespace std;
long long int GCD(long long int a, long long int b) {
  return b == 0 ? a : GCD(b, a % b);
}
long long int LCM(long long int a, long long int b) {
  return a * (b / GCD(a, b));
}
int a[300000], b[300000];
int main() {
  int t;
  cin >> t;
  for (int ca = int(1); ca <= int(t); ca++) {
    int n;
    cin >> n;
    long long int x, aodd = 0, aeven = 0;
    for (int i = int(1); i <= int(n); i++) {
      cin >> x;
      if (x % 2)
        aodd++;
      else
        aeven++;
    }
    int m;
    cin >> m;
    long long int bodd = 0, beven = 0;
    for (int i = int(1); i <= int(m); i++) {
      cin >> x;
      if (x % 2)
        bodd++;
      else
        beven++;
    }
    long long int total = (aodd * bodd) + (aeven * beven);
    cout << total << '\n';
  }
  return 0;
}
