#include <bits/stdc++.h>
using namespace std;
int t, a, b, c, ans;
int p[10][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0},
                {1, 0, 1}, {0, 1, 1}, {1, 1, 1}};
void dfs(int k, int a, int b, int c, int num) {
  if (k == 7) {
    ans = max(ans, num);
    return;
  }
  dfs(k + 1, a, b, c, num);
  if (a >= p[k][0] && b >= p[k][1] && c >= p[k][2])
    dfs(k + 1, a - p[k][0], b - p[k][1], c - p[k][2], num + 1);
}
int main() {
  cin >> t;
  while (t--) {
    cin >> a >> b >> c;
    ans = 0;
    dfs(0, a, b, c, 0);
    cout << ans << endl;
  }
  return 0;
}
