#include <bits/stdc++.h>
const long long int M = 1e9 + 7;
using namespace std;
int main() {
  long long int n, a, b, c, d, x, y, x1, x2, y1, y2, e, f, t, m;
  cin >> t;
  vector<int> v;
  vector<int> p;
  while (t--) {
    cin >> n;
    c = 0;
    d = 0;
    while (n--) {
      cin >> a;
      v.push_back(a);
      if (a % 2 == 0)
        c++;
      else
        d++;
    }
    cin >> m;
    while (m--) {
      cin >> b;
      p.push_back(b);
    }
    x1 = 0;
    for (int i = 0; i < p.size(); i++) {
      if (p[i] % 2 == 0) {
        x1 += c;
      } else {
        x1 += d;
      }
    }
    cout << x1 << "\n";
    v.clear();
    p.clear();
  }
  return 0;
}
