#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7;
int n, mv[3];
long long a[MAXN];
int sg[MAXN][3], cnt[5], prd, bound;
map<deque<int>, int> pos;
void predeal() {
  pos.clear();
  deque<int> dq;
  for (int i = 1;; i++) {
    int s = 0;
    for (int j = 0; j <= 2; j++) {
      memset(cnt, 0, sizeof(cnt));
      for (int k = 0; k <= 2; k++)
        if (j == 0 || k == 0 || j != k) {
          cnt[sg[max(0, i - mv[k])][k]]++;
        }
      sg[i][j] = 0;
      while (cnt[sg[i][j]]) sg[i][j]++;
      assert(sg[i][j] < 4);
      s = s * 4 + sg[i][j];
    }
    dq.push_back(s);
    if (dq.size() > 5) dq.pop_front();
    if (dq.size() == 5) {
      if (pos.count(dq)) {
        prd = i - pos[dq];
        bound = i;
        return;
      } else
        pos[dq] = i;
    }
  }
}
int getsg(long long i, int j) {
  if (i > bound) {
    i -= (i - bound) / prd * prd;
    while (i > bound) i -= prd;
  }
  assert(i <= bound);
  return sg[i][j];
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d", &n, &mv[0], &mv[1], &mv[2]);
    predeal();
    int sum = 0, ans = 0;
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), sum ^= getsg(a[i], 0);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= 2; j++)
        if ((sum ^ getsg(a[i], 0) ^ getsg(max(0ll, a[i] - mv[j]), j)) == 0)
          ans++;
    printf("%d\n", ans);
  }
  return 0;
}
