#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    long long a1 = 0, a0 = 0;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] % 2)
        a1++;
      else
        a0++;
    }
    int m;
    cin >> m;
    long long b1 = 0, b0 = 0;
    long long brr[m];
    for (int i = 0; i < m; i++) {
      cin >> brr[i];
      if (brr[i] % 2)
        b1++;
      else
        b0++;
    }
    long long cnt = a0 * b0 + a1 * b1;
    cout << cnt << endl;
    ;
  }
}
