#include <bits/stdc++.h>
using namespace std;
inline void speedUp() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long int t, n, m, p[100005], q[100005], Podd, Peven, Qodd, Qeven, tot;
int main() {
  speedUp();
  int t, n;
  cin >> t;
  while (t--) {
    tot = Podd = Peven = Qodd = Qeven = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> p[i];
      if (p[i] % 2 == 0)
        Peven++;
      else
        Podd++;
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
      cin >> q[i];
      if (q[i] % 2 == 0)
        Qeven++;
      else
        Qodd++;
    }
    for (int i = 1; i <= n; i++) {
      if (p[i] % 2 == 0)
        tot += Qeven;
      else
        tot += Qodd;
    }
    cout << tot << endl;
  }
}
