#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 1, inf = 1e9 + 7;
long long g[3 * 101], a[maxn];
long long mex(long long x, long long y, long long z) {
  long long ans = 0;
  while (!x || !y || !z) {
    ++ans;
    --x;
    --y;
    --z;
  }
  return ans;
}
long long f(long long x, long long cf, long long ci, long long ccl) {
  if (x < 0) return 0;
  if (x <= ci) return g[3 * x + cf];
  return g[3 * (ci + 1 + (x - ci - 1) % ccl) + cf];
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, x, y, z;
    cin >> n >> x >> y >> z;
    for (long long i = 1; i <= 100; i++) {
      long long nx = max(0ll, i - x), ny = max(0ll, i - y),
                nz = max(0ll, i - z);
      g[3 * i] = mex(g[3 * nx], g[3 * ny + 1], g[3 * nz + 2]);
      g[3 * i + 1] = mex(g[3 * nx], g[3 * nz + 2], g[3 * nz + 2]);
      g[3 * i + 2] = mex(g[3 * nx], g[3 * ny + 1], g[3 * ny + 1]);
    }
    long long ccl = 0, ci = 0;
    for (long long j = 99; j >= 0; j -= 2) {
      long long cl = (101 - j) / 2, fg = 1;
      for (long long first = j; first < j + cl; first++)
        if (g[3 * first] != g[3 * (first + cl)] ||
            g[3 * first + 1] != g[3 * (first + cl) + 1] ||
            g[3 * first + 2] != g[3 * (first + cl) + 2]) {
          fg = 0;
          break;
        }
      if (fg) {
        ccl = cl;
        ci = j + cl - 1;
      }
    }
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long can = 0;
    for (long long i = 0; i < n; i++) can ^= f(a[i], 0, ci, ccl);
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      long long cx = can ^ f(a[i], 0, ci, ccl);
      if (cx == f(a[i] - x, 0, ci, ccl)) ++cnt;
      if (cx == f(a[i] - y, 1, ci, ccl)) ++cnt;
      if (cx == f(a[i] - z, 2, ci, ccl)) ++cnt;
    }
    cout << cnt << '\n';
  }
  return 0;
}
