#include <bits/stdc++.h>
int out(int a, int b, int c) {
  int output = 0;
  if (a > 0 && b > 0) {
    output++;
    a--;
    b--;
  }
  if (a > 0 && c > 0) {
    output++;
    a--;
    c--;
  }
  if (b > 0 && c > 0) {
    output++;
    b--;
    c--;
  }
  return output;
}
void out2(int *a, int *b, int *c) {
  if (*a > 0 && *b > 0) {
    *a -= 1;
    *b -= 1;
  }
  if (*a > 0 && *c > 0) {
    *a -= 1;
    *c -= 1;
  }
  if (*b > 0 && *c > 0) {
    *b -= 1;
    *c -= 1;
  }
}
int findMax(int *a, int *b, int *c) {
  int arr[6];
  arr[0] = out(*a, *b, *c);
  arr[1] = out(*a, *c, *b);
  arr[2] = out(*b, *c, *a);
  arr[3] = out(*b, *a, *c);
  arr[4] = out(*c, *a, *b);
  arr[5] = out(*c, *b, *a);
  int output = 0, index = 0;
  for (int i = 0; i < 6; i++)
    if (arr[i] > output) {
      output = arr[i];
      index = i;
    }
  switch (index) {
    case 0:
      out2(a, b, c);
      break;
    case 1:
      out2(a, c, b);
      break;
    case 2:
      out2(b, c, a);
      break;
    case 3:
      out2(b, a, c);
      break;
    case 4:
      out2(c, a, b);
      break;
    case 5:
      out2(c, b, a);
      break;
  }
  return output;
}
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int a, b, c;
    int output = 0;
    scanf("%d %d %d", &a, &b, &c);
    if (a > 0) {
      output++;
      a--;
    }
    if (b > 0) {
      output++;
      b--;
    }
    if (c > 0) {
      output++;
      c--;
    }
    output += findMax(&a, &b, &c);
    if (a > 0 && b > 0 && c > 0) {
      output++;
      a--;
      b--;
      c--;
    }
    printf("%d\n", output);
  }
  return 0;
}
