#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, t1 = 1, flag = 1, cou = 0, cou1 = 0;
    cin >> a >> b >> c;
    int a1 = a, b1 = b, c1 = c;
    string s[] = {"100", "010", "001", "110", "011", "101", "111"};
    string s1[] = {"100", "010", "001", "011", "101", "110", "111"};
    string s2[] = {"100", "010", "001", "101", "110", "011", "111"};
    for (int i = 0; i < 7; i++) {
      if (a - (t1 * (s[i][0] - '0')) >= 0 && b - (t1 * (s[i][1] - '0')) >= 0 &&
          c - (t1 * (s[i][2] - '0')) >= 0) {
        a -= t1 * (s[i][0] - '0');
        flag = 1;
        b -= t1 * (s[i][1] - '0');
        c -= t1 * (s[i][2] - '0');
        cou++;
      }
    }
    if (cou1 < cou) cou1 = cou;
    cou = 0;
    a = a1;
    b = b1;
    c = c1;
    for (int i = 0; i < 7; i++) {
      if (a - (t1 * (s1[i][0] - '0')) >= 0 &&
          b - (t1 * (s1[i][1] - '0')) >= 0 &&
          c - (t1 * (s1[i][2] - '0')) >= 0) {
        a -= t1 * (s1[i][0] - '0');
        flag = 1;
        b -= t1 * (s1[i][1] - '0');
        c -= t1 * (s1[i][2] - '0');
        cou++;
      }
    }
    if (cou1 < cou) cou1 = cou;
    cou = 0;
    a = a1;
    b = b1;
    c = c1;
    for (int i = 0; i < 7; i++) {
      if (a - (t1 * (s2[i][0] - '0')) >= 0 &&
          b - (t1 * (s2[i][1] - '0')) >= 0 &&
          c - (t1 * (s2[i][2] - '0')) >= 0) {
        a -= t1 * (s2[i][0] - '0');
        flag = 1;
        b -= t1 * (s2[i][1] - '0');
        c -= t1 * (s2[i][2] - '0');
        cou++;
      }
    }
    if (cou1 < cou) cou1 = cou;
    cout << cou1 << endl;
  }
}
