#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, a, m, ne = 0, no = 0, me = 0, mo = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      if (a % 2 == 0)
        ne++;
      else
        no++;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> a;
      if (a % 2 == 0)
        me++;
      else
        mo++;
    }
    cout << ne * me + no * mo << endl;
  }
}
