#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    unsigned long long cnt = 0, od1, ev1, od2, ev2;
    od1 = od2 = ev1 = ev2 = 0;
    int n;
    cin >> n;
    unsigned long long arr1[n];
    for (int i = 0; i < n; i++) {
      cin >> arr1[i];
      if (arr1[i] & 1)
        od1++;
      else
        ev1++;
    }
    int m;
    cin >> m;
    unsigned long long arr2[m];
    for (int i = 0; i < m; i++) {
      cin >> arr2[i];
      if (arr2[i] & 1)
        od2++;
      else
        ev2++;
    }
    cnt = od1 * od2 + ev1 * ev2;
    printf("%llu\n", cnt);
  }
}
