#include <bits/stdc++.h>
using namespace std;
int x(int y) {
  if (y > 0)
    return 1;
  else
    return 0;
}
int x(int *y, int *z) {
  if (*y > 0 && *z > 0) {
    --*y;
    --*z;
    return 1;
  } else
    return 0;
}
int main() {
  int test;
  cin >> test;
  while (test--) {
    int arr[3], a, b, c, t = 0;
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3, greater<int>());
    a = arr[0];
    b = arr[1];
    c = arr[2];
    t = t + x(a) + x(b) + x(c);
    a--;
    b--;
    c--;
    t = t + x(&a, &b) + x(&b, &c) + x(&c, &a);
    if (a > 0 && b > 0 && c > 0) t++;
    cout << t << endl;
  }
}
