#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  int a, b, c;
  int ans;
  cin >> T;
  while (T--) {
    cin >> a >> b >> c;
    if (a > 4) a = 4;
    if (b > 4) b = 4;
    if (c > 4) c = 4;
    if (a > b) swap(a, b);
    if (a > c) swap(a, c);
    if (b > c) swap(b, c);
    if (a == 4)
      ans = 7;
    else if (a == 3)
      ans = 6;
    else if (a == 2) {
      if (b == 2) {
        if (c >= 3)
          ans = 5;
        else
          ans = 4;
      } else
        ans = 5;
    } else if (a == 1) {
      if (b == 1)
        ans = 3;
      else
        ans = 4;
    } else {
      if (b == 0) {
        if (c >= 1)
          ans = 1;
        else
          ans = 0;
      } else if (b == 1)
        ans = 2;
      else
        ans = 3;
    }
    cout << ans << endl;
  }
  return 0;
}
