#include <bits/stdc++.h>
using namespace std;
void nhap1();
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    nhap1();
  }
  return 0;
}
void nhap1() {
  int DSC;
  cin >> DSC;
  int f1 = 0, f2 = 0;
  while (DSC > 0) {
    int n;
    cin >> n;
    if (n % 2 == 0) {
      f2++;
    } else {
      f1++;
    }
    DSC--;
  }
  long long res = 0;
  cin >> DSC;
  while (DSC > 0) {
    int n;
    cin >> n;
    if (n % 2 == 0) {
      res += f2;
    } else {
      res += f1;
    }
    DSC--;
  }
  cout << res << endl;
}
