#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T read() {
  T x = 0, w = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') w = -w;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * w;
}
template <class T>
inline T read(T& x) {
  return x = read<T>();
}
const int N = 3e5 + 10, K = 5;
long long a[N];
map<vector<array<int, 3> >, int> d;
vector<array<int, 3> > s;
void real_main() {
  int n = read<int>();
  int x = read<int>(), y = read<int>(), z = read<int>();
  for (int i = 1; i <= n; ++i) read(a[i]);
  function<int(vector<int>)> mex = [&](vector<int> a) -> int {
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    if (a[0] > 0) return 0;
    for (int i = 1; i < (int)a.size(); ++i)
      if (a[i] > a[i - 1] + 1) return a[i - 1] + 1;
    return a.size();
  };
  function<vector<array<int, 3> >(vector<array<int, 3> >)> go =
      [&](vector<array<int, 3> > s) -> vector<array<int, 3> > {
    array<int, 3> f;
    f[0] = mex({s[K - x][0], s[K - y][1], s[K - z][2]});
    f[1] = mex({s[K - x][0], s[K - z][2]});
    f[2] = mex({s[K - x][0], s[K - y][1]});
    s.erase(s.begin()), s.push_back(f);
    return s;
  };
  d.clear();
  vector<array<int, 3> > cur(K, {0, 0, 0});
  int cnt = 0;
  s.clear();
  while (!d.count(cur)) {
    d[cur] = cnt;
    s.push_back(cur.back());
    cur = go(cur), ++cnt;
  }
  int p = cnt - d[cur], pp = cnt - p;
  function<int(long long, int)> calc = [&](long long x, int t) -> int {
    if (x < cnt)
      return s[x][t];
    else
      return s[pp + (x - pp) % p][t];
  };
  int sum = 0;
  for (int i = 1; i <= n; ++i) sum ^= calc(a[i], 0);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    sum ^= calc(a[i], 0);
    ans += sum == calc(max(0LL, a[i] - x), 0);
    ans += sum == calc(max(0LL, a[i] - y), 1);
    ans += sum == calc(max(0LL, a[i] - z), 2);
    sum ^= calc(a[i], 0);
  }
  printf("%d\n", ans);
}
int main() {
  for (int T = read<int>(); T--;) real_main();
  return 0;
}
