#include <bits/stdc++.h>
using namespace std;
int T, a[4], ans;
inline bool cmp(int x, int y) { return x > y; }
int main() {
  scanf("%d", &T);
  while (T--) {
    ans = 0;
    scanf("%d%d%d", &a[1], &a[2], &a[3]);
    sort(a + 1, a + 3 + 1, cmp);
    for (int i = 1; i <= 3; ++i) {
      if (a[i]) a[i]--, ans++;
    }
    for (int i = 1; i <= 2; ++i) {
      for (int j = i + 1; j <= 3; ++j) {
        if (a[i] && a[j]) ans++, a[i]--, a[j]--;
      }
    }
    if (a[1] && a[2] && a[3]) ans++;
    cout << ans << endl;
  }
  return 0;
}
