#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a[3], c = 0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[2] != 0) {
      a[2] = a[2] - 1;
      c++;
    }
    if (a[1] != 0) {
      a[1] = a[1] - 1;
      c++;
    }
    if (a[0] != 0) {
      a[0] = a[0] - 1;
      c++;
    }
    if (a[2] != 0 && a[1] != 0) {
      a[2] = a[2] - 1;
      a[1] = a[1] - 1;
      c++;
    }
    if (a[2] != 0 && a[0] != 0) {
      a[2] = a[2] - 1;
      a[0] = a[0] - 1;
      c++;
    }
    if (a[1] != 0 && a[0] != 0) {
      a[1] = a[1] - 1;
      a[0] = a[0] - 1;
      c++;
    }
    if (a[1] != 0 && a[2] != 0 && a[0] != 0) {
      c++;
    }
    cout << c << endl;
  }
}
