#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  long long a, b, cons, j;
  cin >> t;
  while (t--) {
    cin >> a;
    long long odd_a = 0, even_a = 0, odd_b = 0, even_b = 0;
    while (a--) {
      cin >> cons;
      (cons & 1) ? odd_a++ : even_a++;
    }
    cin >> b;
    while (b--) {
      cin >> cons;
      (cons & 1) ? odd_b++ : even_b++;
    }
    cout << even_a * even_b + odd_a * odd_b << endl;
  }
  return 0;
}
