#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    long long n;
    cin >> n;
    long long x;
    long long ctr1 = 0, ctr2 = 0, ctr3 = 0, ctr4 = 0;
    for (long long i = 0; i < n; i++) {
      cin >> x;
      if (x % 2 == 0) {
        ctr1++;
      } else {
        ctr2++;
      }
    }
    long long m;
    cin >> m;
    long long y;
    for (long long i = 0; i < m; i++) {
      cin >> y;
      if (y % 2 == 0) {
        ctr3++;
      } else {
        ctr4++;
      }
    }
    long long sum = ((ctr2 * ctr4) + (ctr1 * ctr3));
    cout << sum << endl;
  }
  return 0;
}
