#include <bits/stdc++.h>
using namespace std;
int dp[4][630], rpt;
long long a[300100];
int T;
int n, x, y, z;
long long xo;
int mex(vector<int> v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  v.push_back(2e9);
  for (int i = 0;; i++) {
    if ((v[i] ^ i)) {
      return i;
    }
  }
}
int mixe(int i) { return max(0, i - x); }
int infa(int i) { return max(0, i - y); }
int cava(int i) { return max(0, i - z); }
long long mixell(long long i) { return max(0LL, i - (long long)(x)); }
long long infall(long long i) { return max(0LL, i - (long long)(y)); }
long long cavall(long long i) { return max(0LL, i - (long long)(z)); }
int dyid;
int get(int tp, long long id) {
  if (id > 200) return dp[tp][(id - 200) % rpt + 200];
  return dp[tp][id];
}
void Sprague_Grundy_dp() {
  dp[1][0] = 0;
  dp[2][0] = 0;
  dp[3][0] = 0;
  rpt = -1;
  bool ok;
  for (int i = 1; i <= 300 && rpt < 0; i++) {
    dp[1][i] = mex({dp[1][mixe(i)], dp[2][infa(i)], dp[3][cava(i)]});
    dp[2][i] = mex({dp[1][mixe(i)], dp[3][cava(i)]});
    dp[3][i] = mex({dp[1][mixe(i)], dp[2][infa(i)]});
    if (i <= 200) continue;
    ok = true;
    for (int k = 0; k < 5; k++)
      ok &= ((dp[1][200 - k] == dp[1][i - k]) &&
             (dp[2][200 - k] == dp[2][i - k]) &&
             (dp[3][200 - k] == dp[3][i - k]));
    if (ok) rpt = i;
  }
  rpt -= 200;
}
void solve() {
  cin >> n >> x >> y >> z;
  Sprague_Grundy_dp();
  xo = 0LL;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    xo ^= get(1, a[i]);
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    xo ^= get(1, a[i]);
    dyid = i;
    if (!(get(1, mixell(a[i])) ^ xo)) res++;
    if (!(get(2, infall(a[i])) ^ xo)) res++;
    if (!(get(3, cavall(a[i])) ^ xo)) res++;
    dyid = -1;
    xo ^= get(1, a[i]);
  }
  cout << res << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> T;
  while (T--) solve();
  return 0;
}
