#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const long long int INF = LLONG_MAX;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n;
    long long int neven = 0, nodd = 0, meven = 0, modd = 0;
    for (long long int i = 0; i <= n - 1; i++) {
      long long int temp;
      cin >> temp;
      if (temp % 2 == 0)
        neven++;
      else
        nodd++;
    }
    cin >> m;
    for (long long int i = 0; i <= m - 1; i++) {
      long long int temp;
      cin >> temp;
      if (temp % 2 == 0)
        meven++;
      else
        modd++;
    }
    long long int ans = nodd * modd + neven * meven;
    cout << ans << endl;
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
