#include <bits/stdc++.h>
using namespace std;
long long n, m, k, l, t, zz, kk, zz2, kk2;
int main() {
  cin >> t;
  while (t) {
    zz = 0;
    kk = 0;
    zz2 = 0;
    kk2 = 0;
    l = 0;
    t--;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> k;
      if (k % 2 == 0)
        zz++;
      else
        kk++;
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> k;
      if (k % 2 == 0)
        zz2++;
      else
        kk2++;
    }
    cout << kk * kk2 + zz * zz2 << endl;
  }
  return 0;
}
