#include <bits/stdc++.h>
using namespace std;
long long n, ans;
string str;
long long solve() {
  long long e1 = 0, o1 = 0, e2 = 0, o2 = 0;
  cin >> n;
  for (long long i = 0; i < (n); ++i) {
    long long a;
    cin >> a;
    if (a % 2)
      e1++;
    else
      o1++;
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < (m); ++i) {
    long long a;
    cin >> a;
    if (a % 2)
      e2++;
    else
      o2++;
  }
  cout << e1 * e2 + o1 * o2 << "\n";
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
