#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  for (int ab = 0; ab < (t); ++ab) {
    int n, m;
    cin >> n;
    int elem;
    long long eCnt = 0, oCnt = 0;
    for (int i = 0; i < (n); ++i) {
      cin >> elem;
      if (elem % 2 == 1)
        oCnt++;
      else
        eCnt++;
    }
    cin >> m;
    int tot = 0;
    long long oeCnt = 0, ooCnt = 0;
    for (int i = 0; i < (m); ++i) {
      cin >> elem;
      if (elem % 2 == 1)
        ooCnt++;
      else
        oeCnt++;
    }
    cout << oeCnt * eCnt + ooCnt * oCnt << endl;
  }
  return 0;
}
