#include <bits/stdc++.h>
using namespace std;
const long long N = 500005;
const long long mod = 1e9 + 7;
void solve() {
  long long x = 0, y = 0, c = 0, ans = 0;
  long long n, m, k;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> k;
    if (k % 2 == 0) x++;
  }
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    cin >> k;
    if (k % 2 == 0) y++;
  }
  cout << x * y + (n - x) * (m - y) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
