#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool palin(string s) {
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - i - 1]) return 0;
  }
  return 1;
}
void solve() {
  vector<long long> a(3);
  for (long long i = 0; i < 3; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<long long>());
  long long ct = 0;
  for (long long i = 0; i < 3; i++)
    if (a[i] > 0) {
      a[i]--;
      ct++;
    }
  if (a[0] > 0 && a[1] > 0) {
    a[0]--;
    a[1]--;
    ct++;
  }
  if (a[0] > 0 && a[2] > 0) {
    a[0]--;
    a[2]--;
    ct++;
  }
  if (a[1] > 0 && a[2] > 0) {
    a[1]--;
    a[2]--;
    ct++;
  }
  if (a[0] > 0 && a[1] > 0 && a[2] > 0) ct++;
  cout << ct;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
}
