#include <bits/stdc++.h>
const long double pi = 3.14159265359;
const long long N = 1e6 + 3;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> q;
  for (int k = 0; k < q; k++) {
    long long n, arrn[100005], arrm[100005], m = 0, ne[100005] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arrn[i];
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> arrm[i];
      if (arrm[i] % 2 == 0)
        ne[2]++;
      else
        ne[1]++;
    }
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
      if (arrn[i] % 2 == 0)
        cnt += ne[2];
      else
        cnt += ne[1];
    }
    cout << cnt << endl;
  }
  return 0;
}
