#include <bits/stdc++.h>
using namespace std;
int maxi(int a, int b, int c) {
  return a > b ? (a > c ? a : c) : (b > c ? b : c);
}
int mini(int a, int b, int c) {
  return a < b ? (a < c ? a : c) : (b < c ? b : c);
}
int mid(int a, int b, int c) {
  return a > b ? (b > c ? b : (a < c ? a : c)) : (a > c ? a : (b < c ? b : c));
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    int A = maxi(a, b, c);
    int B = mid(a, b, c);
    int C = mini(a, b, c);
    if (A > 0) {
      count++;
      A--;
    }
    if (B > 0) {
      count++;
      B--;
    }
    if (C > 0) {
      count++;
      C--;
    }
    if (C >= 2) {
      count += 3;
      A -= 2;
      B -= 2;
      C -= 2;
    } else if (B >= 2) {
      count++;
      A--;
      B--;
      if (C > 0) {
        count++;
        B--;
        C--;
      }
    } else if (A >= 2) {
      if (B > 0) {
        count++;
        A--;
        B--;
      }
      if (C > 0) {
        count++;
        A--;
        C--;
      }
    } else {
      if (A > 0 && B > 0) {
        count++;
        A--;
        B--;
      }
    }
    if (A > 0 && B > 0 && C > 0) count++;
    cout << count << endl;
  }
}
