#include <bits/stdc++.h>
using namespace std;
const int N = 300043;
int x, y, z, n;
long long a[N];
map<vector<vector<int> >, int> mp;
int cur, cycle;
vector<vector<int> > rem;
int mex(vector<int> a) {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  for (int i = 0; i < a.size(); i++)
    if (a[i] != i) return i;
  return a.size();
}
vector<int> make_vector(int a, int b, int c = -1) {
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  if (c != -1) v.push_back(c);
  return v;
}
vector<vector<int> > nxt(vector<vector<int> > s) {
  int f0 = mex(make_vector(s[0][5 - x], s[1][5 - y], s[2][5 - z]));
  int f1 = mex(make_vector(s[0][5 - x], s[2][5 - z]));
  int f2 = mex(make_vector(s[0][5 - x], s[1][5 - y]));
  s[0].erase(s[0].begin());
  s[0].push_back(f0);
  s[1].erase(s[1].begin());
  s[1].push_back(f1);
  s[2].erase(s[2].begin());
  s[2].push_back(f2);
  return s;
}
void predone() {
  vector<vector<int> > s(3, vector<int>(5, 0));
  cur = 0;
  mp.clear();
  rem.clear();
  while (!mp.count(s)) {
    mp[s] = cur;
    rem.push_back(make_vector(s[0].back(), s[1].back(), s[2].back()));
    s = nxt(s);
    cur++;
  }
  cycle = cur - mp[s];
}
int get_grundy(long long x, int t) {
  if (x < cur)
    return rem[x][t];
  else {
    int st = cur - cycle;
    x -= st;
    return rem[st + (x % cycle)][t];
  }
}
void read() {
  scanf("%d %d %d %d", &n, &x, &y, &z);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
}
int check(int x, int y) { return x == y ? 1 : 0; }
void solve() {
  predone();
  int ans = 0;
  for (int i = 0; i < n; i++) ans ^= get_grundy(a[i], 0);
  int res = 0;
  for (int i = 0; i < n; i++) {
    ans ^= get_grundy(a[i], 0);
    res += check(ans, get_grundy(max(0ll, a[i] - x), 0));
    res += check(ans, get_grundy(max(0ll, a[i] - y), 1));
    res += check(ans, get_grundy(max(0ll, a[i] - z), 2));
    ans ^= get_grundy(a[i], 0);
  }
  printf("%d\n", res);
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    read();
    solve();
  }
}
