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