#include <bits/stdc++.h>
using namespace std;
long long const N = 200005, M = 1002, mod = 1000000007;
long long n, m, k, t, i, j, ans, kaskad[N];
long long arr[] = {4, 2, 1, 6, 5, 3, 7};
void solve() {
  long long a[3];
  for (int i = 0; i < 3; ++i) cin >> a[i];
  ans = 0;
  for (int i = 0; i < 7; ++i) {
    if (i == 0 || i == 3) sort(a, a + 3);
    long long y = arr[i], j = 0, x[3]{};
    while (y != 0) {
      x[j++] = y % 2;
      y /= 2;
    }
    if (a[0] >= x[0] && a[1] >= x[1] && a[2] >= x[2]) {
      a[0] -= x[0];
      a[1] -= x[1];
      a[2] -= x[2];
      ans++;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tt = 1;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
