#include <bits/stdc++.h>
using namespace std;
int n, T, x, y, z;
long long a[300007];
int sg[207], sgn1[207], sgn2[207], ok[207][3];
int zk[6][6][6];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d", &n, &x, &y, &z);
    memset(ok, 0, sizeof ok);
    sg[0] = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
    }
    int mm = max(x, max(y, z));
    for (int i = 1; i <= 200; i++) {
      int vv[4] = {0}, vvn1[4] = {0}, vvn2[4] = {0};
      if (i <= x) {
        vv[sg[0]] = 1;
        vvn1[sg[0]] = 1;
        vvn2[sg[0]] = 1;
      } else {
        vv[sg[i - x]] = 1;
        vvn1[sg[i - x]] = 1;
        vvn2[sg[i - x]] = 1;
      }
      if (i <= y) {
        vv[sgn1[0]] = 1;
        vvn2[sgn1[0]] = 1;
      } else {
        vv[sgn1[i - y]] = 1;
        vvn2[sgn1[i - y]] = 1;
      }
      if (i <= z) {
        vv[sgn2[0]] = 1;
        vvn1[sgn2[0]] = 1;
      } else {
        vv[sgn2[i - z]] = 1;
        vvn1[sgn2[i - z]] = 1;
      }
      for (int j = 0; j < 4; j++) {
        if (!vv[j]) {
          sg[i] = j;
          break;
        }
      }
      for (int j = 0; j < 4; j++) {
        if (!vvn1[j]) {
          sgn1[i] = j;
          break;
        }
      }
      for (int j = 0; j < 4; j++) {
        if (!vvn2[j]) {
          sgn2[i] = j;
          break;
        }
      }
    }
    int xxx = 100;
    for (int xh = 1; xh <= 10; xh++) {
      int flag = 1;
      for (int i = 70; i <= 190; i++) {
        if (sg[i] != sg[i + xh] || sgn1[i] != sgn1[i + xh] ||
            sgn2[i] != sgn2[i + xh]) {
          flag = 0;
          break;
        }
      }
      if (flag) {
        xxx = xh;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      a[i] = a[i] < 100 ? a[i] : (a[i] - 70) % xxx + 70;
    }
    long long ans = 0;
    int ssg = 0;
    for (int i = 0; i < n; i++) {
      ssg ^= sg[a[i]];
    }
    if (ssg == 0) {
      puts("0");
    } else {
      for (int i = 0; i < n; i++) {
        if (sg[a[i]] == 0) {
          if ((ssg ^ sg[a[i] - x]) == 0) ans++;
          if ((ssg ^ sgn1[a[i] - y]) == 0) ans++;
          if ((ssg ^ sgn2[a[i] - z]) == 0) ans++;
        }
        if (sg[a[i]] != 0) {
          if ((ssg ^ sg[a[i]] ^ sg[max(0ll, a[i] - x)]) == 0) ans++;
          if ((ssg ^ sg[a[i]] ^ sgn1[max(0ll, a[i] - y)]) == 0) ans++;
          if ((ssg ^ sg[a[i]] ^ sgn2[max(0ll, a[i] - z)]) == 0) ans++;
        }
      }
      printf("%d\n", ans);
    }
  }
}
