#include <bits/stdc++.h>
using namespace std;
const int nmax = int(3e5) + 5;
const int defThres = 100;
int n, a[4], b[nmax], d[nmax][4], thres, res, ans;
set<int> sg;
bool checkCycle(int k) {
  for (int j = 0; j < 3; ++j) {
    for (int i = thres / 2; i <= thres; ++i) {
      if (d[i][j] != d[i - k][j]) return false;
    }
  }
  return true;
}
void solve() {
  scanf("%d%d%d%d", &n, &a[0], &a[1], &a[2]);
  thres = defThres;
  res = ans = 0;
  for (int i = 1; i <= thres; ++i) {
    for (int j = 0; j < 3; ++j) {
      sg.clear();
      for (int k = 0; k < 3; ++k) {
        if ((j & k) == 0) sg.insert(d[max(0, i - a[k])][k]);
      }
      d[i][j] = 0;
      while (sg.find(d[i][j]) != sg.end()) ++d[i][j];
    }
  }
  int cycle = 1;
  while (!checkCycle(cycle)) ++cycle;
  thres = thres - thres % cycle - cycle;
  cerr << cycle << endl;
  cerr << thres << endl;
  for (int i = 1; i <= n; ++i) {
    long long k;
    scanf("%lld", &k);
    if (k > thres) k = thres + k % cycle;
    b[i] = int(k);
    res ^= d[b[i]][0];
  }
  if (res > 0) {
    for (int i = 1; i <= n; ++i) {
      for (int k = 0; k < 3; ++k) {
        if ((res ^ d[b[i]][0] ^ d[max(0, b[i] - a[k])][k]) == 0) ++ans;
      }
    }
  }
  printf("%d\n", ans);
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) solve();
  return 0;
}
