#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long inf = 5e9 + 7;
const long long max_n = 1e5 + 3, K = 5;
long long n, x, y, z;
map<vector<vector<long long>>, long long> d;
long long cnt, p;
vector<vector<long long>> state_log;
long long mex(vector<long long> a) {
  sort(a.begin(), a.end());
  long long r = 0;
  for (long long i : a) {
    if (i > r) return r;
    if (i == r) r++;
  }
  return r;
}
void go(vector<vector<long long>>& cur) {
  long long f1 = mex({cur[0][K - x], cur[1][K - y], cur[2][K - z]});
  long long f2 = mex({cur[0][K - x], cur[2][K - z]});
  long long f3 = mex({cur[0][K - x], cur[1][K - y]});
  for (long long i = 0; i < 3; i++) cur[i].erase(cur[i].begin());
  cur[0].emplace_back(f1), cur[1].emplace_back(f2), cur[2].emplace_back(f3);
}
void prec() {
  vector<vector<long long>> cur(3, vector<long long>(K));
  state_log.clear();
  cnt = p = 0;
  d.clear();
  while (!d.count(cur)) {
    state_log.push_back({cur[0].back(), cur[1].back(), cur[2].back()});
    d[cur] = cnt;
    cnt++;
    go(cur);
  }
  p = cnt - d[cur];
}
long long f(long long a, long long t) {
  if (a < cnt)
    return state_log[a][t];
  else {
    a -= (cnt - p);
    return state_log[a % p + (cnt - p)][t];
  }
}
void solve() {
  cin >> n >> x >> y >> z;
  prec();
  long long res = 0, num = 0;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    num ^= f(a[i], 0);
  }
  for (long long i = 0; i < n; i++) {
    num ^= f(a[i], 0);
    res += f(max(0ll, a[i] - x), 0) == num;
    res += f(max(0ll, a[i] - y), 1) == num;
    res += f(max(0ll, a[i] - z), 2) == num;
    num ^= f(a[i], 0);
  }
  cout << res << endl;
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  cout.precision(10);
  long long t;
  cin >> t;
  while (t--) solve();
}
