#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long vis1[2], vis2[2];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    memset(vis1, 0, sizeof(vis1));
    memset(vis2, 0, sizeof(vis2));
    for (int i = 0; i < n; i++) {
      long long a;
      cin >> a;
      vis1[a % 2]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      long long a;
      cin >> a;
      vis2[a % 2]++;
    }
    cout << vis1[0] * vis2[0] + vis1[1] * vis2[1] << '\n';
  }
}
