#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
int n, x, y, z, sg[110][3], T, L = 50;
long long a[N];
int mex(set<int> st) {
  for (int i = 0;; i++)
    if (st.find(i) == st.end()) return i;
}
vector<int> get(int l) {
  vector<int> ret;
  for (int j = 0; j < 3; j++) ret.push_back(sg[l][j]);
  return ret;
}
void getT() {
  for (T = 1;; T++) {
    int bo = 1;
    for (int i = 50; i + T <= 100; i++)
      if (get(i) != get(i + T)) {
        bo = 0;
        break;
      }
    if (bo) break;
  }
}
int getsg(long long i, int j) {
  if (i <= 100) return sg[i][j];
  return sg[(i - L) % T + L][j];
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d %d %d", &n, &x, &y, &z);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= 100; i++) {
      for (int j = 0; j < 3; j++) {
        sg[i][j] =
            mex({sg[max(0, i - x)][0], sg[max(0, i - y)][1] + 100 * (j == 1),
                 sg[max(0, i - z)][2] + 100 * (j == 2)});
      }
    }
    getT();
    int nowsg = 0, ans = 0;
    for (int i = 1; i <= n; i++) nowsg ^= getsg(a[i], 0);
    for (int i = 1; i <= n; i++) {
      nowsg ^= getsg(a[i], 0);
      int bo = 0;
      if ((nowsg ^ getsg(max(a[i] - x, 0ll), 0)) == 0) ans++;
      if ((nowsg ^ getsg(max(a[i] - y, 0ll), 1)) == 0) ans++;
      if ((nowsg ^ getsg(max(a[i] - z, 0ll), 2)) == 0) ans++;
      nowsg ^= getsg(a[i], 0);
    }
    printf("%d\n", ans);
  }
  return 0;
}
