#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, a = 0, c = 0;
    cin >> n;
    long long int p[n];
    for (long long int i = 0; i < n; i++) {
      cin >> p[i];
      if (p[i] % 2 == 0) {
        a++;
      }
    }
    long long int b = n - a;
    cin >> m;
    long long int q[m];
    for (long long int i = 0; i < m; i++) {
      cin >> q[i];
      if (q[i] % 2 == 0) {
        c++;
      }
    }
    long long int d = m - c;
    long long int res = (a * c) + (b * d);
    cout << res << "\n";
  }
}
