#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = (1e18);
const ll mod = 1000000007;
const ll mod2 = 998244353;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<ll> p(n);
    ll oddp = 0, evenp = 0;
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      if (p[i] % 2 == 1)
        oddp++;
      else
        evenp++;
    }
    ll ans = 0;
    int m;
    cin >> m;
    vector<ll> q(m);
    for (int i = 0; i < m; i++) {
      cin >> q[i];
      if (q[i] % 2 == 1)
        ans += oddp;
      else
        ans += evenp;
    }
    cout << ans << endl;
  }
}
