#include <bits/stdc++.h>
using namespace std;
long long mex(set<long long> s) {
  for (long long i = 0; i <= 4; i++)
    if (s.find(i) == s.end()) return i;
}
long long x, y, z;
namespace sg {
long long sg[105][4];
long long I, J;
long long getsg(long long t, long long c) {
  if (t < J) return sg[t][c];
  return sg[J + (t - J) % (I - J)][c];
}
void clear() {
  I = 0;
  J = 0;
  memset(sg, 0, sizeof sg);
}
void calc(long long ai) {
  for (long long i = 1;; i++) {
    set<long long> s;
    s.insert(sg[max(0ll, i - x)][0]);
    s.insert(sg[max(0ll, i - y)][1]);
    s.insert(sg[max(0ll, i - z)][2]);
    sg[i][0] = mex(s);
    s.clear();
    s.insert(sg[max(0ll, i - x)][0]);
    s.insert(sg[max(0ll, i - z)][2]);
    sg[i][1] = mex(s);
    s.clear();
    s.insert(sg[max(0ll, i - x)][0]);
    s.insert(sg[max(0ll, i - y)][1]);
    sg[i][2] = mex(s);
    for (long long j = 4; j < i - 4; j++) {
      long long fg = 1;
      for (long long k = 0; k <= 4; k++) {
        for (long long u = 0; u < 3; u++) {
          if (sg[j - k][u] != sg[i - k][u]) fg = 0;
        }
      }
      if (fg) {
        I = i;
        J = j;
        return;
      }
    }
  }
}
}  // namespace sg
long long t, n, a[300005], ssg[300005][3], osg[300005];
signed main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n >> x >> y >> z;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    sg::clear();
    sg::calc(0);
    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
      osg[i] = sg::getsg(a[i], 0);
      sum ^= osg[i];
      ssg[i][0] = sg::getsg(max(0ll, a[i] - x), 0);
      ssg[i][1] = sg::getsg(max(0ll, a[i] - y), 1);
      ssg[i][2] = sg::getsg(max(0ll, a[i] - z), 2);
    }
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      if ((sum ^ osg[i] ^ ssg[i][0]) == 0) ++ans;
      if ((sum ^ osg[i] ^ ssg[i][1]) == 0) ++ans;
      if ((sum ^ osg[i] ^ ssg[i][2]) == 0) ++ans;
    }
    cout << ans << endl;
  }
}
