#include <bits/stdc++.h>
long long mod;
long long mul(long long x, long long y) {
  return (x * y - (long long)(x / (long double)mod * y + 1e-3) * mod + mod) %
         mod;
}
inline int read() {
  int res = 0;
  char ch = getchar();
  bool fu = 0;
  while (!isdigit(ch)) fu |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
  return fu ? -res : res;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a < b) {
      int temp = a;
      a = b;
      b = temp;
    }
    if (a < c) {
      int temp = a;
      a = c;
      c = temp;
    }
    if (b < c) {
      int temp = b;
      b = c;
      c = temp;
    }
    int ans = 0;
    if (a > 0) {
      ans++;
      a--;
    }
    if (b > 0) {
      ans++;
      b--;
    }
    if (c > 0) {
      ans++;
      c--;
    }
    if (a > 0 && b > 0) {
      ans++;
      a--;
      b--;
    }
    if (b > 0 && c > 0) {
      ans++;
      b--;
      c--;
    }
    if (a > 0 && c > 0) {
      ans++;
      a--;
      c--;
    }
    if (a > 0 && b > 0 && c > 0) {
      ans++;
    }
    printf("%d\n", ans);
  }
}
