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 \le t \le 500$) — the number of test cases to solve.

Each of the remaining $t$ lines contains integers $a$, $b$ and $c$ ($0 \leq a, b, c \leq 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.

Difficulty: interview

Starter code:

Solutions:
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
 
M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split(' ')]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n').split(' ')]
def li3():return [int(i) for i in input().rstrip('\n')]


for _ in range(val()):
    a,b,c = sorted(li())
    tot = 0
    if a:
        tot += 1
        a -= 1
    if b:
        tot += 1
        b -= 1
    if c:
        tot += 1
        c -= 1
    if b and c:
        tot += 1
        b -= 1
        c -= 1
    if a and c:
        tot += 1
        a -= 1
        c -= 1
    if b and a:
        b -= 1
        a -= 1
        tot += 1
    if a and b and c:
        a -= 1
        b -= 1
        c -= 1
        tot += 1
    print(tot)



#list(map(int,input().split()))
t=int(input())
def brute(ind,su=[0,0,0],co=0):
    nonlocal ma
    if ind==7:
        if su[0]<=a and su[1]<=b and su[2]<=c:
            ma=max(ma,co)
        return
    brute(ind+1,[su[i]+aa[ind][i] for i in range(3)],co+1)
    brute(ind+1,su,co)
for i in range(t):
    a,b,c=list(map(int,input().split()))
    ma=0
    aa=[[1,1,1],[1,1,0],[1,0,0],[1,0,1],[0,1,1],[0,1,0],[0,0,1]]
    brute(0)
    print(ma)


n=int(input())
for _ in range(n):
	a=sorted(list(map(int,input().split())))
	a,b,c=a[2],a[1],a[0]
	ans=0
	if(a):
		ans+=1
		a-=1
	if(b):
		ans+=1
		b-=1
	if(c):
		ans+=1
		c-=1
	if(a>0 and b>0):
		ans+=1
		a-=1
		b-=1
	if(b>0 and c>0):
		ans+=1
		b-=1
		c-=1
	if(a>0 and c>0):
		ans+=1
		a-=1
		c-=1
	if(a>0 and b>0 and c>0):
		ans+=1
	print(ans)


from itertools import permutations
for _ in range(int(input())):
    ans = 0
    a, b, c = list(map(int, input().split()))
    for x, y, z in permutations((a, b, c)):
        cnt = 0
        if x:
            cnt += 1
            x -= 1
        if y:
            cnt += 1
            y -= 1
        if z:
            cnt += 1
            z -= 1
        if x and y:
            x -= 1
            y -= 1
            cnt += 1
        if y and z:
            y -= 1
            z -= 1
            cnt += 1
        if x and z:
            x -= 1
            z -= 1
            cnt += 1
        if x and y and z:
            cnt += 1

        ans = max(ans, cnt)

    print(ans)


t = int(input())
for q in range(t):
    a = list(map(int, input().split()))
    ans = 0
    for i in range(3):
        if a[i] > 0:
            ans += 1
            a[i] -= 1
    a.sort()
    a.reverse()
    if a[0] and a[1]:
        a[0] -= 1
        a[1] -= 1
        ans += 1
    if a[0] and a[2]:
        a[0] -= 1
        a[2] -= 1
        ans += 1
    if a[1] and a[2]:
        a[1] -= 1
        a[2] -= 1
        ans += 1
    if a[0] and a[1] and a[2]:
        ans += 1
    print(ans)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = int(1.5e6)
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
for _ in range(int(input())):
    a,b,c = sorted(arrIN(),reverse=True)
    ans = 0
    if a>0:
        ans+=1
        a-=1
    if b>0:
        ans+=1
        b-=1
    if c>0:
        ans+=1
        c-=1
    if a>0:
        if b>0:
            ans+=1
            a-=1
            b-=1
    if a>0:
        if c>0:
            ans+=1
            a-=1
            c-=1
    if b>0:
        if c>0:
            ans+=1
            b-=1
            c-=1
    if a>0 and b>0 and c>0:
        ans+=1
    print(ans)



TC = int(input())

for _ in range(TC):
    a, b, c = list(map(int, input().split()))

    nums = sorted((a, b, c))

    cnt = 0
    for i in range(2, -1, -1):
        if nums[i] > 0:
            nums[i] -= 1
            cnt += 1

    if nums[2] > 0 and nums[1] > 0:
        cnt += 1
        nums[2] -= 1
        nums[1] -= 1

    if nums[2] > 0 and nums[0] > 0:
        cnt += 1
        nums[2] -= 1
        nums[0] -= 1


    if nums[1] > 0 and nums[0] > 0:
        cnt += 1
        nums[1] -= 1
        nums[0] -= 1

    if all(nums):
        cnt += 1

    print(cnt)


import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
go = lambda : 1/0
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}{}".format(i, sep))
INF = float('inf')
MOD = int(1e9 + 7)
YES = "YES"
NO = "NO"

for _ in range(int(input())):
  try:
    a, b, c = read()

    ans = 0

    if a >= 1:
      a -= 1
      ans += 1
    
    if b >= 1:
      b -= 1
      ans += 1

    if c >= 1:
      c -= 1
      ans += 1

    if a >= 2:
      if b >= 1:
        a -= 1
        b -= 1
        ans += 1
      if c >= 1:
        a -= 1
        c -= 1
        ans += 1
      if b >= 1 and c >= 1:
        b -= 1
        c -= 1 
        ans += 1

    elif b >= 2:
      if a >= 1:
        a -= 1
        b -= 1
        ans += 1
      if c >= 1:
        b -= 1
        c -= 1
        ans += 1
      if a >= 1 and c >= 1:
        a -= 1
        c -= 1 
        ans += 1
        
    elif c >= 2:
      if a >= 1:
        a -= 1
        c -= 1
        ans += 1
      if b >= 1:
        b -= 1
        c -= 1
        ans += 1
      if a >= 1 and b >= 1:
        a -= 1
        b -= 1 
        ans += 1
    else:
      if a >= 1 and b >= 1:
        a -= 1
        b -= 1
        ans += 1
      if c >= 1 and b >= 1:
        c -= 1
        b -= 1
        ans += 1
      if a >= 1 and c >= 1:
        a -= 1
        c -= 1
        ans += 1
          
    if a>=1 and b>=1 and c>=1:
      ans += 1
    
    print(ans)


      
      



  except ZeroDivisionError:
    continue

  except Exception as e:
    print(e)
    continue

import sys
input = sys.stdin.readline

T = int(input())

for _ in range(T):
    D = list(map(int, input().split()))
    ans = 0
    for i in range(3):
        if D[i]:
            D[i] -= 1
            ans += 1

    D.sort(reverse=True)
    for i in range(2):
        for j in range(i+1, 3):
            if D[i] and D[j]:
                D[i] -= 1
                D[j] -= 1
                ans += 1
    if D[0] and D[1] and D[2]:
        ans += 1

    print(ans)


t = int(input())

for k in range(t):
    a, b, c = list(map(int, input().split()))

    d = [a, b, c]
    d.sort()
    a = 0

    if d[0] > 0:
        a += 1
        d[0] -= 1

    if d[1] > 0:
        a += 1
        d[1] -= 1

    if d[2] > 0:
        a += 1
        d[2] -= 1

    d.sort(reverse=True)

    if d[0] > 0 and d[1] > 0:
        a += 1
        d[0] -= 1
        d[1] -= 1

    if d[0] > 0 and d[2] > 0:
        a += 1
        d[0] -= 1
        d[2] -= 1

    if d[2] > 0 and d[1] > 0:
        a += 1
        d[2] -= 1
        d[1] -= 1

    if d[0] > 0 and d[1] > 0 and d[2] > 0:
        a += 1

    print(a)


t = int(input())
while t:
    t -= 1
    arr = list(map(int, input().split()))
    a, b, c = sorted(arr, reverse=True)
    ans = 0
    if a:
        ans += 1
        a -= 1
    if b:
        ans += 1
        b -= 1
    if c:
        ans += 1
        c -= 1
    if a and b:
        ans += 1
        a -= 1
        b -= 1
    if a and c:
        ans += 1
        a -= 1
        c -= 1
    if b and c:
        ans += 1
        b -= 1
        c -= 1
    if a and b and c:
        ans += 1
    print(ans)