#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7, test;
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int min(long long int a, long long int b) { return a > b ? b : a; }
void solve() {
  long long int n;
  cin >> n;
  long long int a[2] = {0, 0}, b[2] = {0, 0};
  for (long long int i = 0; i < (n); i++) {
    cin >> test;
    a[test % 2]++;
  }
  long long int m;
  cin >> m;
  for (long long int i = 0; i < (m); i++) {
    cin >> test;
    b[test % 2]++;
  }
  cout << (a[0] * b[0] + a[1] * b[1]) << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
