#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  long long idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ", ";
  dbs(str.substr(idx + 1), s...);
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
template <class T>
void prall(T a) {
  prc(a.begin(), a.end());
}
const int inf = 1000 * 1000 * 1000 + 9;
const long long infl = 1ll * inf * inf;
const int mod = 1000 * 1000 * 1000 + 7;
void solve() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int o = 0, e = 0;
    for (int i = 0; i < n; i++) {
      int p;
      cin >> p;
      if (p & 1)
        o++;
      else
        e++;
    }
    long long ans = 0;
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      int p;
      cin >> p;
      if (p & 1) {
        ans += o;
      } else
        ans += e;
    }
    cout << ans << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout << fixed << setprecision(13);
  solve();
}
