#include <bits/stdc++.h>
using namespace std;
inline void FAST_IO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <class F, class S>
ostream& operator<<(ostream& os, pair<F, S>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  os << "(";
  if (v.size()) os << v[0];
  for (int i = 1; i < v.size(); ++i) os << "," << v[i];
  os << ")";
  return os;
}
int main() {
  FAST_IO();
  int t;
  cin >> t;
  while (t-- > 0) {
    int n, m;
    cin >> n;
    long long counta[2]{0}, countb[2]{0};
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      counta[x % 2]++;
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
      int x;
      cin >> x;
      countb[x % 2]++;
    }
    cout << (countb[0] * counta[0] + counta[1] * countb[1]) << endl;
  }
  return 0;
}
