#include <bits/stdc++.h>
using namespace std;
int vis[15];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a[3];
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < 3; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      if (a[i] - 1 >= 0) {
        a[i]--;
        ans++;
      }
      vis[a[i]]++;
    }
    if (vis[0] == 1 || vis[1] == 3)
      printf("%d\n", ans + 1);
    else if (vis[0] == 2 || vis[0] == 3)
      printf("%d\n", ans);
    else if (vis[1] == 1 || vis[1] == 2)
      printf("%d\n", ans + 2);
    else if (vis[2])
      printf("%d\n", ans + 3);
    else
      printf("%d\n", ans + 4);
  }
}
