#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int c;
    c = 0;
    vector<int> a(3);
    for (auto &x : a) cin >> x;
    for (int i = 0; i < 3; i++) {
      if (a[i] > 0) {
        a[i]--;
        c++;
      }
    }
    sort(a.begin(), a.end());
    if (a[2] > 0 and a[1] > 0) {
      c++;
      a[2]--;
      a[1]--;
    }
    if (a[2] > 0 and a[0] > 0) {
      c++;
      a[2]--;
      a[0]--;
    }
    if (a[0] > 0 and a[1] > 0) {
      c++;
      a[0]--;
      a[1]--;
    }
    if (a[0] >= 1 && a[1] >= 1 && a[2] >= 1) c++;
    cout << c << "\n";
  }
}
