#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long double PI = 2 * acos(0.0);
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int cont = 0;
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    vector<vector<int> > c(7);
    c[0].push_back(0);
    c[0].push_back(1);
    c[0].push_back(2);
    c[1].push_back(0);
    c[1].push_back(1);
    c[2].push_back(0);
    c[2].push_back(2);
    c[3].push_back(1);
    c[3].push_back(2);
    c[4].push_back(0);
    c[5].push_back(1);
    c[6].push_back(2);
    sort(c.begin(), c.end());
    int mx = 0;
    do {
      vector<int> w;
      w = v;
      int cont = 0;
      for (int i = 0; i < 7; i++) {
        int q = 0;
        for (int j = 0; j < c[i].size(); j++) {
          if (w[c[i][j]] > 0) {
            w[c[i][j]]--;
          } else {
            q++;
          }
        }
        if (q == 0) {
          cont++;
        }
      }
      mx = max(cont, mx);
    } while (next_permutation(c.begin(), c.end()));
    cout << mx << "\n";
  }
  return 0;
}
