#include <bits/stdc++.h>
using namespace std;
int p[100001], q[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n, m;
  cin >> t;
  long long int res = 0, ces = 0, temp = 0, tamp = 0;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> p[i];
      if (p[i] % 2 == 0) {
        res++;
      } else {
        ces++;
      }
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
      cin >> q[i];
      if (q[i] % 2 == 0) {
        temp++;
      } else {
        tamp++;
      }
    }
    cout << res * temp + ces * tamp << endl;
    res = 0, ces = 0, temp = 0, tamp = 0;
  }
  return 0;
}
