#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long p_odd = 0, p_even = 0, q_odd = 0, q_even = 0;
    int n;
    cin >> n;
    long long p[n];
    for (long long i = (0); i < (n); i++) {
      cin >> p[i];
      (p[i] & 1) ? p_odd++ : p_even++;
    }
    int m;
    cin >> m;
    long long q[m];
    for (long long i = (0); i < (m); i++) {
      cin >> q[i];
      (q[i] & 1) ? q_odd++ : q_even++;
    }
    cout << p_odd * q_odd + p_even * q_even << endl;
  }
  return 0;
}
