#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;
const double eps = 1e-7;
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) {
  for (const auto &x : xs)
    if (!(x >= 0 && x < t)) return false;
  return true;
}
int ceillog2(ll x) { return int(ceil(log2(x))); }
int floorlog2(ll x) { return int(floor(log2(x))); }
template <class T>
T reversed(T container) {
  reverse(container.begin(), container.end());
  return container;
}
template <class T>
void printv(const vector<T> &v) {
  for (const T &x : v) cout << x << " ";
  cout << "\n";
}
template <class T>
void printmx(const vector<vector<T>> &mx) {
  for (const vector<T> &v : mx) printv(v);
}
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) {
  ll m = (ll)sqrt((double)x);
  return m + (m * m <= x ? 0 : -1);
}
ll ceilsqrt(ll x) {
  ll m = (ll)sqrt((double)x);
  return m + (x <= m * m ? 0 : 1);
}
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) {
  if (n == 0)
    return m;
  else
    return gcd(n, m % n);
}
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }
int mex(const vi &a) {
  std::vector<bool> b(a.size() + 1, false);
  for (const auto &x : a) {
    if (x <= a.size()) b[x] = true;
  }
  for (int i = 0; i < b.size(); ++i) {
    if (!b[i]) return i;
  }
  return INT_MAX;
}
struct pre_t {
  array<array<int, 3>, 200> dp;
  int T;
};
pre_t solve_pre(const vi &x) {
  pre_t ret;
  for (int j = 0; j < int(3); j++) {
    ret.dp[0][j] = 0;
  }
  for (int i = 1; i <= int(199); i++) {
    for (int j = 0; j < int(3); j++) {
      vi u;
      for (int k = 0; k < int(3); k++) {
        if (j == 1 && k == 1) continue;
        if (j == 2 && k == 2) continue;
        u.push_back(ret.dp[max(0, i - x[k])][k]);
      }
      ret.dp[i][j] = mex(u);
    }
  }
  for (int i = int(193) - 1; i >= 0; i--) {
    bool judge = true;
    int T = 199 - i;
    for (int d = 0; d < int(T); d++) {
      for (int k = 0; k < int(3); k++) {
        if (ret.dp[199 - d][k] != ret.dp[i - d][k]) {
          judge = false;
          break;
        }
      }
      if (!judge) break;
    }
    if (judge) {
      ret.T = T;
      break;
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  pre_t pres[6][6][6];
  for (int x = 1; x <= int(5); x++) {
    for (int y = 1; y <= int(5); y++) {
      for (int z = 1; z <= int(5); z++) {
        vi a = {x, y, z};
        pres[x][y][z] = solve_pre(a);
      }
    }
  }
  int q;
  cin >> q;
  for (int _ = 0; _ < int(q); _++) {
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    vi r = {x, y, z};
    vll a(n);
    for (int i = 0; i < int(n); i++) cin >> a[i];
    vector<array<int, 3>> b(n);
    for (int i = 0; i < int(n); i++) {
      for (int j = 0; j < int(3); j++) {
        ll k = 0;
        if (a[i] - r[j] < 200)
          k = 0;
        else
          k = ceildiv(a[i] + r[j] - 190, pres[x][y][z].T);
        b[i][j] =
            pres[x][y][z].dp[max(0LL, a[i] - r[j] - k * pres[x][y][z].T)][j];
      }
    }
    vi c(n);
    int sum = 0;
    for (int i = 0; i < int(n); i++) {
      vi buf = {b[i][0], b[i][1], b[i][2]};
      c[i] = mex(buf);
      sum ^= c[i];
    }
    int ans = 0;
    for (int i = 0; i < int(n); i++) {
      for (int j = 0; j < int(3); j++) {
        int buf = sum ^ c[i] ^ b[i][j];
        if (buf == 0) {
          ans++;
        }
      }
    }
    cout << ans << "\n";
  }
}
