#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, i, j, c = 0, l = 0;
    long long s = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> j;
      if (j % 2 != 0)
        l++;
      else
        c++;
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> j;
      if (j % 2 == 0)
        s = s + c;
      else
        s = s + l;
    }
    cout << s << "\n";
  }
}
