#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10, mod = 998244353;
int n, m, k, t;
long long a[maxn];
int sg[510][3];
int period;
int mex(int x, int y, int z) {
  if (x > y) swap(x, y);
  if (x > z) swap(x, z);
  if (y > z) swap(y, z);
  int ret = 0;
  if (ret == x) ret++;
  if (ret == y) ret++;
  if (ret == z) ret++;
  return ret;
}
int mex(int x, int y) {
  if (x > y) swap(x, y);
  int ret = 0;
  if (ret == x) ret++;
  if (ret == y) ret++;
  return ret;
}
void init_sg(int x, int y, int z) {
  for (int i = 1; i <= 500; i++) {
    sg[i][0] =
        mex(sg[max(i - x, 0)][0], sg[max(i - y, 0)][1], sg[max(i - z, 0)][2]);
    sg[i][1] = mex(sg[max(i - x, 0)][0], sg[max(i - z, 0)][2]);
    sg[i][2] = mex(sg[max(i - x, 0)][0], sg[max(i - y, 0)][1]);
  }
  period = -1;
  for (int i = 1;; i++) {
    bool f = true;
    for (int j = 500; j >= 400; j--) {
      for (int k = 0; k < 3; k++) {
        if (sg[j][k] != sg[j - i][k]) {
          f = false;
          break;
        }
      }
      if (!f) break;
    }
    if (f) {
      period = i;
      break;
    }
  }
}
int get_sg(long long x, int y) {
  if (x < 0) return 0;
  if (x <= 500) return sg[x][y];
  return sg[(x - 400) % period + 400][y];
}
int main() {
  int i, j;
  scanf("%d", &t);
  while (t--) {
    int x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    for (i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
    }
    init_sg(x, y, z);
    int win = 0;
    for (i = 1; i <= n; i++) {
      win ^= get_sg(a[i], 0);
    }
    if (!win)
      puts("0");
    else {
      int ret = 0;
      for (i = 1; i <= n; i++) {
        if ((win ^ get_sg(a[i], 0) ^ get_sg(a[i] - x, 0)) == 0) ret++;
        if ((win ^ get_sg(a[i], 0) ^ get_sg(a[i] - y, 1)) == 0) ret++;
        if ((win ^ get_sg(a[i], 0) ^ get_sg(a[i] - z, 2)) == 0) ret++;
      }
      printf("%d\n", ret);
    }
  }
  return 0;
}
