#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n;
    long long jj = 0, jo = 0;
    long long dj = 0, doo = 0;
    for (int i = 1; i <= n; i++) {
      int c;
      cin >> c;
      if (c % 2)
        jj++;
      else
        jo++;
    }
    cin >> m;
    for (int j = 1; j <= m; j++) {
      int c;
      cin >> c;
      if (c % 2)
        dj++;
      else
        doo++;
    }
    cout << jj * dj + jo * doo << endl;
  }
  return 0;
}
