#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, flag = 0, temp = 0, curr = 0, sum = 0;
    cin >> n;
    long long int a[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 == 0)
        flag++;
      else
        temp++;
    }
    cin >> m;
    long long int b[m + 1];
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      if (b[i] % 2 == 0)
        sum += flag;
      else
        curr += temp;
    }
    cout << sum + curr << endl;
  }
  return 0;
}
