#include <bits/stdc++.h>
using namespace std;
void solve() {
  int i, ar[3];
  cin >> ar[0] >> ar[1] >> ar[2];
  int person = 0;
  for (i = 0; i < 3; i++)
    if (ar[i] > 0) {
      ar[i]--;
      person++;
    }
  sort(ar, ar + 3);
  if (ar[0] > 0 && ar[2] > 0) {
    person++;
    ar[0]--;
    ar[2]--;
  }
  if (ar[1] > 0 && ar[2] > 0) {
    person++;
    ar[2]--;
    ar[1]--;
  }
  if (ar[0] > 0 && ar[1] > 0) {
    person++;
    ar[0]--;
    ar[1]--;
  }
  if (ar[0] && ar[1] && ar[2]) {
    person++;
  }
  cout << person << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int T = 1;
  cin >> T;
  while (T--) solve();
  return 0;
}
