#include <bits/stdc++.h>
template <class T>
bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
int Mex(vector<ll> A) {
  for (ll i = 0; i < 1000000007; i++) {
    bool found = false;
    for (auto x : A) {
      if (x == i) {
        found = true;
        break;
      }
    }
    if (!found) {
      return i;
    }
  }
  return 0;
}
void Main() {
  ll Q;
  cin >> Q;
  while (Q--) {
    ll N, x[3];
    cin >> N >> x[0] >> x[1] >> x[2];
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) cin >> A[i];
    const int NN = 100;
    ll dp[3][NN] = {};
    auto getdp = [&](int f, ll sz) {
      if (sz <= 0) return 0LL;
      return dp[f][sz];
    };
    for (ll i = 1; i < NN; i++) {
      dp[0][i] =
          Mex({getdp(0, i - x[0]), getdp(1, i - x[1]), getdp(2, i - x[2])});
      dp[1][i] = Mex({getdp(0, i - x[0]), getdp(2, i - x[2])});
      dp[2][i] = Mex({getdp(0, i - x[0]), getdp(1, i - x[1])});
    }
    int per = -1;
    for (ll i = 5; i < 11; i++) {
      bool ok = true;
      for (ll j = 0; j < i; j++) {
        if (!ok) break;
        for (ll k = 0; k < 3; k++) {
          if (dp[k][NN - i - j - 1] != dp[k][NN - j - 1]) {
            ok = false;
            break;
          }
        }
      }
      if (ok) {
        per = i;
        break;
      }
    }
    auto getGrundy = [&](int f, ll a) {
      if (a >= NN) {
        a -= (a - NN) / per * per;
        a -= per;
      }
      return getdp(f, a);
    };
    ll ans = 0;
    ll sum = 0;
    for (ll i = 0; i < N; i++) {
      sum ^= getGrundy(0, A[i]);
    }
    for (ll i = 0; i < N; i++) {
      ll buf = sum ^ getGrundy(0, A[i]);
      for (ll j = 0; j < 3; j++) {
        ll desu = buf ^ getGrundy(j, A[i] - x[j]);
        if (desu == 0) ++ans;
      }
    }
    cout << ans << "\n";
  }
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
