#include <bits/stdc++.h>
using namespace std;
void Solve() {
  long n;
  long long a[2] = {0};
  long x;
  cin >> n;
  for (long i = 0; i < n; i++) {
    cin >> x;
    a[x % 2]++;
  }
  long m;
  cin >> m;
  long long b[2] = {0};
  for (long i = 0; i < m; i++) {
    cin >> x;
    b[x % 2]++;
  }
  cout << a[0] * b[0] + a[1] * b[1] << endl;
}
int main() {
  int t;
  cin >> t;
  int i = 1;
  while (t--) {
    Solve();
    i++;
  }
  return 0;
}
