#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n--) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int ans = 0;
    for (int i = 0; i < 3; i++)
      if (a[i]) {
        ans++;
        a[i]--;
      }
    int mx = max(a[0], max(a[1], a[2]));
    int mn = min(a[0], min(a[1], a[2]));
    a[1] = a[0] + a[1] + a[2] - mn - mx;
    a[0] = mx;
    a[2] = mn;
    for (int i = 0; i < 3; i++)
      for (int j = i + 1; j < 3; j++)
        if (a[i] && a[j]) {
          a[i]--;
          a[j]--;
          ans++;
        }
    ans += min(1, min(a[0], min(a[1], a[2])));
    cout << ans << endl;
  }
  cin >> n;
}
