#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int t;
int n, m;
int a[N], b[N], x;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int l = 0, r = 0;
    cin >> m;
    for (int i = 1; i <= m; i++) {
      cin >> x;
      if (x % 2 == 0)
        l++;
      else
        r++;
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] % 2 == 0)
        res += l;
      else
        res += r;
    }
    cout << res << endl;
  }
}
