#include <bits/stdc++.h>
using namespace std;
void arrinitialize(long long n, long long a[], long long x) {
  for (long long(i) = 0; (i) <= (n - 1); (i) += (1)) {
    a[i] = x;
  }
}
void arrinput1(long long n, long long a[]) {
  for (long long(i) = 1; (i) <= (n); (i) += (1)) cin >> a[i];
}
void arrinput0(long long n, long long a[]) {
  for (long long(i) = 0; (i) <= (n - 1); (i) += (1)) cin >> a[i];
}
void start() {}
struct p {
  long long l, r, d;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  start();
  long long query;
  cin >> query;
  while (query--) {
    long long a[3];
    for (long long(i) = 0; (i) <= (2); (i) += (1)) cin >> a[i];
    long long s = 0;
    for (long long(i) = 0; (i) <= (2); (i) += (1)) {
      if (a[i] > 0) {
        a[i]--;
        s++;
      }
    }
    sort(a, a + 3);
    long long k = a[2];
    a[2] = a[0];
    a[0] = k;
    for (long long(i) = 0; (i) <= (2); (i) += (1)) {
      for (long long(j) = i + 1; (j) <= (2); (j) += (1)) {
        if (a[j] > 0 && a[i] > 0) {
          a[j]--;
          a[i]--;
          s++;
        }
      }
    }
    if (a[0] > 0 && a[1] > 0 && a[2] > 0) s++;
    cout << s << endl;
  }
}
