#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n, m;
  int a, b;
  for (int q = 0; q < t; q++) {
    long long hasil = 0;
    int genap = 0, ganjil = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      if (a % 2 == 0) {
        genap++;
      } else {
        ganjil++;
      }
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> b;
      if (b % 2 == 0) {
        hasil += genap;
      } else {
        hasil += ganjil;
      }
    }
    cout << hasil << endl;
  }
}
