#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000")
#pragma warning(disable : 6031)
#pragma warning(disable : 4244)
#pragma warning(disable : 26451)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const long long LINF = 1e18;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << setprecision(18) << fixed;
  int t;
  cin >> t;
  while (t--) {
    vector<int> a(3);
    for (auto& x : a) cin >> x;
    int res = 0;
    vector<int> order(7);
    iota((order).begin(), (order).end(), 1);
    do {
      vector<int> at = a;
      int cr = 0;
      for (int i = 0; i < (int)(order).size(); i++) {
        bool ok = true;
        int cur = order[i];
        for (int j = 0; j < 3; j++) {
          if ((cur & 1 << j) && at[j] == 0) {
            ok = false;
            break;
          }
        }
        if (ok) {
          cr++;
          for (int j = 0; j < 3; j++)
            if (cur & 1 << j) at[j]--;
        }
      }
      res = max(res, cr);
    } while (next_permutation((order).begin(), (order).end()));
    cout << res << "\n";
  }
  return 0;
}
