#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    c = v[0];
    b = v[1];
    a = v[2];
    int count = 0;
    if (a >= 1) {
      a = a - 1;
      count = count + 1;
    }
    if (b >= 1) {
      b = b - 1;
      count = count + 1;
    }
    if (c >= 1) {
      c = c - 1;
      count = count + 1;
    }
    if (a >= 1 && b >= 1) {
      a = a - 1;
      b = b - 1;
      count = count + 1;
    }
    if (a >= 1 && c >= 1) {
      c = c - 1;
      a = a - 1;
      count = count + 1;
    }
    if (b >= 1 && c >= 1) {
      b = b - 1;
      c = c - 1;
      count = count + 1;
    }
    if (a >= 1 && b >= 1 && c >= 1) {
      count = count + 1;
    }
    cout << count << "\n";
  }
}
