Tired of boring office work, Denis decided to open a fast food restaurant.

On the first day he made a portions of dumplings, b portions of cranberry juice and c pancakes with condensed milk.

The peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis himself chooses a set of dishes that this visitor will receive. When doing so, Denis is guided by the following rules:

  * every visitor should receive at least one dish (dumplings, cranberry juice, pancakes with condensed milk are all considered to be dishes); 
  * each visitor should receive no more than one portion of dumplings, no more than one portion of cranberry juice and no more than one pancake with condensed milk; 
  * all visitors should receive different sets of dishes. 



What is the maximum number of visitors Denis can feed?

Input

The first line contains an integer t (1 ≤ t ≤ 500) — the number of test cases to solve.

Each of the remaining t lines contains integers a, b and c (0 ≤ a, b, c ≤ 10) — the number of portions of dumplings, the number of portions of cranberry juice and the number of condensed milk pancakes Denis made.

Output

For each test case print a single integer — the maximum number of visitors Denis can feed.

Example

Input

7
1 2 1
0 0 0
9 1 7
2 2 3
2 3 2
3 2 2
4 4 4


Output

3
0
4
5
5
5
7

Note

In the first test case of the example, Denis can feed the first visitor with dumplings, give the second a portion of cranberry juice, and give the third visitor a portion of cranberry juice and a pancake with a condensed milk.

In the second test case of the example, the restaurant Denis is not very promising: he can serve no customers.

In the third test case of the example, Denise can serve four visitors. The first guest will receive a full lunch of dumplings, a portion of cranberry juice and a pancake with condensed milk. The second visitor will get only dumplings. The third guest will receive a pancake with condensed milk, and the fourth guest will receive a pancake and a portion of dumplings. Please note that Denis hasn't used all of the prepared products, but is unable to serve more visitors.
#include <bits/stdc++.h>
const long long kot = LLONG_MAX;
using kk = long double;
const int MAXIT = 100;
const long long int alpha = 1e18;
using namespace std;
long long int gcd(long long int a, long long int begin) {
  if (begin == 0) return a;
  return gcd(begin, a % begin);
}
long long int largest(long long int arr[], long long int n) {
  return *max_element(arr, arr + n);
}
long long int lcm(long long int a, long long int begin) {
  return (a * begin) / gcd(a, begin);
}
void sieve(bool primes[], long long int x) {
  primes[1] = false;
  for (long long int i = 2; i * i <= x; i++) {
    if (primes[i] == true) {
      for (long long int j = 2; j * i <= x; j++) primes[i * j] = false;
    }
  }
}
long long int power(long long int x, unsigned long long int y,
                    long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
class gfg {
 public:
  long long int sumDigits(long long int no) {
    return no == 0 ? 0 : no % 10 + sumDigits(no / 10);
  }
};
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
bool comp(long long int a, long long int begin) { return (a < begin); }
vector<long long int> ve;
void divisors(long long int n) {
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        ve.push_back(i);
      else
        ve.push_back(i);
      ve.push_back(n / i);
    }
  }
}
bool isPrime(long long int n) {
  if (n == 1) {
    return false;
  }
  long long int i = 2;
  while (i * i <= n) {
    if (n % i == 0) {
      return false;
    }
    i += 1;
  }
  return true;
}
long long int gcdofarray(vector<long long int> &v, long long int n) {
  long long int result = v[0];
  for (long long int i = 1; i < n; i++) result = gcd(v[i], result);
  return result;
}
long long int sumofdigits(long long int n) {
  long long int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
bool powertwo(long long int x) { return x && (!(x & (x - 1))); }
long long int finduncommonsubsequence(string str, string s) {
  if (!str.compare(s)) {
    return 0;
  }
  return max(str.length(), s.length());
}
void reversec(string str) {
  for (long long int i = str.length() - 1; i >= 0; i--) cout << str[i];
}
string removeDuplicatesFromString(string str) {
  long long int counter = 0;
  long long int i = 0;
  long long int size = str.size();
  long long int x;
  long long int length = 0;
  while (i < size) {
    x = str[i] - 97;
    if ((counter & (1 << x)) == 0) {
      str[length] = 'a' + x;
      counter = counter | (1 << x);
      length++;
    }
    i++;
  }
  return str.substr(0, length);
}
long long int commDiv(long long int a, long long int begin) {
  long long int n = gcd(a, begin);
  long long int result = 0;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        result += 1;
      else
        result += 2;
    }
  }
  return result;
}
long long int fact(long long int n) {
  if (n <= 1) return 1;
  return n * fact(n - 1);
}
long long int nPr(long long int n, long long int r) {
  return fact(n) / fact(n - r);
}
long long int kash(long long int a, long long int begin) {
  return (a * begin) / gcd(a, begin);
}
long long int maxi(long long int a, long long int begin) {
  return (a > begin) ? a : begin;
}
long long int mini(long long int a, long long int begin) {
  return (a < begin) ? a : begin;
}
long long int nCr(long long int n, long long int r) {
  return fact(n) / (fact(r) * fact(n - r));
}
long long int nCrModp(long long int n, long long int r, long long int p) {
  long long int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
string add(string str1, string str2) {
  if (str1.length() > str2.length()) swap(str1, str2);
  string str = "";
  long long int n1 = str1.length(), n2 = str2.length();
  long long int diff = n2 - n1;
  long long int carry = 0;
  for (long long int i = n1 - 1; i >= 0; i--) {
    long long int sum = ((str1[i] - '0') + (str2[i + diff] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  for (long long int i = n2 - n1 - 1; i >= 0; i--) {
    long long int sum = ((str2[i] - '0') + carry);
    str.push_back(sum % 10 + '0');
    carry = sum / 10;
  }
  if (carry) str.push_back(carry + '0');
  reverse(str.begin(), str.end());
  return str;
}
long long int powe(long long int x, unsigned long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool sortByVal(const pair<string, long long int> &a,
               const pair<string, long long int> &begin) {
  return (a.second < begin.second);
}
void rev(string str) { reverse(str.begin(), str.end()); }
bool ispalin(string str) {
  long long int l = 0;
  long long int h = str.length() - 1;
  while (h > l) {
    if (str[l++] != str[h--]) {
      return false;
    }
  }
  return true;
}
long long int round(long long int n) {
  long long int a = (n / 10) * 10;
  long long int begin = a + 10;
  return (n - a > begin - n) ? begin : a;
}
void solve() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int arr[3];
    long long int c = 0;
    cin >> arr[0] >> arr[1] >> arr[2];
    if (arr[0] != 0) {
      c++;
      arr[0]--;
    }
    if (arr[1] != 0) {
      c++;
      arr[1]--;
    }
    if (arr[2] != 0) {
      c++;
      arr[2]--;
    }
    sort(arr, arr + 3);
    if (arr[1] != 0 && arr[2] != 0) {
      c++;
      arr[1]--;
      arr[2]--;
    }
    if (arr[2] != 0 && arr[0] != 0) {
      c++;
      arr[2]--;
      arr[0]--;
    }
    if (arr[1] != 0 && arr[0] != 0) {
      c++;
      arr[1]--;
      arr[0]--;
    }
    if (arr[1] > 0 && arr[0] > 0 && arr[2] >> 0) {
      c++;
    }
    cout << c << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
}
