#include <bits/stdc++.h>
using namespace std;
int ara[300005], brr[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int total = 0;
    for (int i = 1; i <= 3; i++) cin >> ara[i];
    sort(ara + 1, ara + 4);
    if (ara[1] == 0) {
      if (ara[2] == 0) {
        if (ara[3] > 0)
          total = 1;
        else
          total = 0;
      } else if (ara[2] == 1)
        total = 2;
      else
        total = 3;
    } else if (ara[1] == 1) {
      if (ara[2] == 1)
        total = 3;
      else
        total = 4;
    } else if (ara[1] == 2) {
      if (ara[2] == 2) {
        if (ara[3] == 2)
          total = 4;
        else
          total = 5;
      } else
        total = 5;
    } else if (ara[1] == 3)
      total = 6;
    else
      total = 7;
    cout << total << endl;
  }
  return 0;
}
