#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const auto &x : v) os << x << " ";
  return os;
}
void solve() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int m;
  cin >> m;
  vector<int> q(m);
  vector<int> cntpi(2, 0);
  for (int i = 0; i < m; i++) {
    cin >> q[i];
    cntpi[q[i] % 2]++;
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] % 2 == 0)
      ans += cntpi[0];
    else
      ans += cntpi[1];
  }
  cout << ans << endl;
}
int main(int argc, char const *argv[]) {
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) solve();
  return 0;
}
