#include <bits/stdc++.h>
int zm, a, b, c, ans;
int bz[9][4];
void dfs(int x, int a, int b, int c, int js) {
  if (x > 7) {
    if (js > ans) ans = js;
    return;
  }
  dfs(x + 1, a, b, c, js);
  if (a - bz[x][1] >= 0 && b - bz[x][2] >= 0 && c - bz[x][3] >= 0)
    dfs(x + 1, a - bz[x][1], b - bz[x][2], c - bz[x][3], js + 1);
}
int main() {
  for (int i = (1); i <= (7); i++)
    for (int j = (1); j <= (3); j++)
      bz[i][j] = ((i & (1 << (j - 1))) > 0 ? 1 : 0);
  scanf("%d", &zm);
  while (zm--) {
    scanf("%d %d %d", &a, &b, &c);
    ans = 0;
    dfs(1, a, b, c, 0);
    printf("%d\n", ans);
  }
  return 0;
}
