#include <bits/stdc++.h>
using namespace std;
int a[3];
int need[3];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    int ans = 0;
    for (int mask_of_mask = 0; mask_of_mask < 1 << 7; mask_of_mask++) {
      need[0] = need[1] = need[2] = 0;
      for (int mask = 1; mask <= 7; mask++) {
        if (mask_of_mask & (1 << (mask - 1))) {
          for (int i = 0; i < 3; i++) {
            need[i] += (mask >> i) & 1;
          }
        }
      }
      if (need[0] > a[0] || need[1] > a[1] || need[2] > a[2]) continue;
      ans = max(ans, __builtin_popcount(mask_of_mask));
    }
    cout << ans << endl;
  }
  return 0;
}
