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: EASY

Solutions:
t = int(input())
for you in range(t):
	l = input().split()
	a = int(l[0])
	b = int(l[1])
	c = int(l[2])
	poss = [1, 2, 3, 4, 5, 6, 7]
	count = [0]
	for i in range(2 ** 7):
		l = []
		for j in range(7):
			if i & 1 << j:
				l.append(poss[j])
		x = 0
		y = 0
		z = 0
		for i in l:
			for k in range(3):
				if 1 << k & i:
					if k == 0:
						x += 1
					if k == 1:
						y += 1
					if k == 2:
						z += 1
		if x <= a and y <= b and (z <= c):
			count.append(len(l))
	print(max(count))


for _ in range(int(input())):
	cnt = 0
	(a, b, c) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	if b < c:
		(b, c) = (c, b)
	if a < b:
		(a, b) = (b, a)
	if a > 0:
		a -= 1
		cnt += 1
	if b > 0:
		b -= 1
		cnt += 1
	if c > 0:
		c -= 1
		cnt += 1
	if a > 0 and b > 0:
		cnt += 1
		a -= 1
		b -= 1
	if c > 0 and a > 0:
		cnt += 1
		c -= 1
		a -= 1
	if b > 0 and c > 0:
		cnt += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
	print(cnt)


n = int(input())
q = []
for i in range(0, n):
	s = 0
	(a, b, c) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	if b < c:
		(c, b) = (b, c)
	if a > 0:
		s += 1
		a -= 1
	if b > 0:
		s += 1
		b -= 1
	if c > 0:
		s += 1
		c -= 1
	if b > 0 and a > 0:
		s += 1
		b -= 1
		a -= 1
	if b > 0 and c > 0:
		s += 1
		c -= 1
		b -= 1
	if a > 0 and c > 0:
		s += 1
		a -= 1
		c -= 1
	if a > 0 and c > 0 and (b > 0):
		s += 1
		a -= 1
		b -= 1
		c -= 1
	q.append(s)
for i in range(0, len(q)):
	print(q[i])


for _ in range(int(input())):
	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)


for _ in range(int(input())):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	l = [a, b, c]
	l.sort()
	if l[2] > 0 and l[1] > 0:
		l[2] -= 1
		l[1] -= 1
		count += 1
	if l[2] > 0 and l[0] > 0:
		l[2] -= 1
		l[0] -= 1
		count += 1
	if l[1] > 0 and l[0] > 0:
		l[1] -= 1
		l[0] -= 1
		count += 1
	if l[0] > 0 and l[1] > 0 and (l[2] > 0):
		l[2] -= 1
		l[1] -= 2
		l[0] -= 1
		count += 1
	print(count)


(t,) = map(int, input().split())
for _ in range(t):
	(a, b, c) = sorted(list(map(int, input().split())))
	if c == 0:
		print(0)
	elif a == 0:
		print(min(b + 1, 3))
	elif a == 1:
		print(min(b + 2, 4))
	elif a == 2:
		if c == 2:
			print(4)
		else:
			print(5)
	elif a == 3:
		print(6)
	else:
		print(7)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		a = LI()
		r = 0
		for k in range(1, 4):
			a.sort(reverse=True)
			for p in itertools.combinations(range(3), k):
				if all((a[i] for i in p)):
					r += 1
					for i in p:
						a[i] -= 1
		rr.append(r)
	return JA(rr, '\n')
print(main())


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


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	(one, two, free) = (True, True, True)
	if a > 0 and b > 0 and (c <= a) and (c <= b):
		a -= 1
		b -= 1
		ans += 1
		one = False
	if b > 0 and c > 0 and (a <= c) and (a <= b):
		b -= 1
		c -= 1
		ans += 1
		two = False
	if a > 0 and c > 0 and (b <= a) and (b <= c):
		a -= 1
		c -= 1
		ans += 1
		free = False
	if one and a > 0 and (b > 0):
		a -= 1
		b -= 1
		ans += 1
	if two and b > 0 and (c > 0):
		b -= 1
		c -= 1
		ans += 1
	if free and a > 0 and (c > 0):
		a -= 1
		c -= 1
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


def solve(a, b, c):
	max = 0
	if a > 0:
		a = a - 1
		max = max + 1
	if b > 0:
		b = b - 1
		max = max + 1
	if c > 0:
		c = c - 1
		max = max + 1
	if a > 0 and c > 0:
		a = a - 1
		c = c - 1
		max = max + 1
	if a > 0 and b > 0:
		a = a - 1
		b = b - 1
		max = max + 1
	if b > 0 and c > 0:
		b = b - 1
		c = c - 1
		max = max + 1
	if a > 0 and b > 0 and (c > 0):
		a = a - 1
		b = b - 1
		c = c - 1
		max = max + 1
	return max
t = int(input())
for case_items in range(t):
	d = list(map(int, input().strip().split()))
	d.sort()
	(a, b, c) = d
	print(solve(a, b, c))


numTest = int(input())
for test in range(numTest):
	a = list(map(int, input().split()))
	res = 0
	for i in range(3):
		if a[i] > 0:
			res += 1
			a[i] -= 1
	a = sorted(a)
	if a[1] > 0 and a[2] > 0:
		a[1] -= 1
		a[2] -= 1
		res += 1
	if a[0] > 0 and a[2] > 0:
		a[0] -= 1
		a[2] -= 1
		res += 1
	if a[0] > 0 and a[1] > 0:
		a[0] -= 1
		a[1] -= 1
		res += 1
	a = sorted(a)
	if a[0] > 0:
		res += 1
	print(res)


for t in range(int(input())):
	m = list(map(int, input().split()))
	m.sort(reverse=True)
	(a, b, c) = (m[0], m[1], m[2])
	s = 0
	if a > 0:
		a -= 1
		s += 1
	if b > 0:
		b -= 1
		s += 1
	if c > 0:
		c -= 1
		s += 1
	if a * b > 0:
		a -= 1
		b -= 1
		s += 1
	if a * c > 0:
		a -= 1
		c -= 1
		s += 1
	if c * b > 0:
		c -= 1
		b -= 1
		s += 1
	if a * b * c > 0:
		s += 1
	print(s)


def smol(n):
	m = int(int(n ** 0.5) * 0.5) - 1
	while 0.5 * (m * (m + 1)) <= n:
		m += 1
	return m - 1
for t in range(int(input())):
	(a, b, c) = (min(int(i), 4) for i in input().split())
	(a, b, c) = sorted([a, b, c])
	ans = 0
	if a >= 1:
		ans += 3
		a -= 1
		b -= 1
		c -= 1
	elif b >= 1:
		ans += 2
		b -= 1
		c -= 1
	elif c >= 1:
		ans += 1
		c -= 1
	if a == 0 and b >= 1:
		ans += 1
		print(ans)
		continue
	if a == 0 and b == 0:
		print(ans)
		continue
	if a == 1 and c >= 2:
		ans += 2
		print(ans)
		continue
	elif a == 1:
		ans += 1
		print(ans)
		continue
	if a == 2:
		ans += 3
		print(ans)
		continue
	if a == 3:
		print(7)
		continue
	print(ans)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a = [min(x, 4) for x in a]
	a.sort()
	a = list(map(str, a))
	n = int(''.join(a))
	arr = [0, 1, 11, 22, 122, 223, 333, 444, 555]
	for i in range(1, 9):
		if n < arr[i]:
			print(i - 1)
			break


import math
for _ in range(int(input())):
	x = sorted(list(map(int, input().split())))
	if x[0] >= 4:
		print(7)
	elif x[2] == 0:
		print(0)
	else:
		cnt = 0
		for i in range(3):
			if x[i] >= 1:
				x[i] -= 1
				cnt += 1
		if x[1] >= 1 and x[2] >= 1:
			x[1] -= 1
			x[2] -= 1
			cnt += 1
		if x[0] >= 1 and x[2] >= 1:
			x[0] -= 1
			x[2] -= 1
			cnt += 1
		if x[0] >= 1 and x[1] >= 1:
			x[0] -= 1
			x[1] -= 1
			cnt += 1
		if min(x) >= 1:
			for i in range(2):
				x[i] -= 1
			cnt += 1
		print(cnt)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	ans = (a > 0) + (b > 0) + (c > 0) + (min(a, b, c) > 3)
	if b > 1 and c > 1:
		ans += 1
		b -= 1
		c -= 1
	if c > 1 and a > 1:
		ans += 1
		a -= 1
	if b > 1 and a > 1:
		ans += 1
	print(ans)


t = int(input())
L = []
for i in range(t):
	l = list(map(int, input().split()))
	sum1 = 0
	l.sort()
	for i in range(len(l)):
		if l[i] > 0:
			l[i] -= 1
			sum1 += 1
	M = max(l)
	M_index = 2
	if M > 0:
		for i in range(len(l)):
			if not i == M_index and l[M_index] > 0:
				if l[i] > 0:
					l[M_index] -= 1
					l[i] -= 1
					sum1 += 1
	if l[0] > 0 and l[1] > 0:
		l[0] -= 1
		l[1] -= 1
		sum1 += 1
	if l[0] > 0 and l[1] > 0 and (l[1] > 0):
		sum1 += 1
	L.append(sum1)
print(*L, sep='\n')


from bisect import bisect
l = '001 011 022 122 223 333 444'.split()
for _ in range(int(input())):
	print(bisect(l, '{}{}{}'.format(*sorted((min(int(s), 4) for s in input().split())))))


import sys
t = int(sys.stdin.readline())
for c in range(t):
	array = list(map(int, sys.stdin.readline().split()))
	total = 0
	for i in range(3):
		if array[i] != 0:
			total += 1
			array[i] -= 1
	array.sort()
	if array[2] != 0:
		if array[1] != 0:
			total += 1
			array[2] -= 1
			array[1] -= 1
	if array[0] > array[2] and array[2] != 0:
		total += 1
		array[0] -= 1
		array[2] -= 1
	elif array[2] != 0 and array[0] != 0:
		total += 1
		array[0] -= 1
		array[2] -= 1
	if array[1] != 0 and array[0] != 0:
		total += 1
		array[1] -= 1
		array[0] -= 1
	if min(array) != 0:
		total += 1
	print(total)


t = int(input())
for case in range(t):
	x = [int(s) for s in input().split(' ')]
	x.sort(reverse=True)
	cnt = 0
	for i in range(len(x)):
		if x[i] > 0:
			x[i] -= 1
			cnt += 1
	for i in range(len(x)):
		for j in range(i + 1, len(x)):
			if min(x[i], x[j]) > 0:
				x[i] -= 1
				x[j] -= 1
				cnt += 1
	if min(x) > 0:
		cnt += 1
	print(cnt)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c == 0:
		print(0)
	elif a == b == 0 or b == c == 0 or a == c == 0:
		print(1)
	elif a == 0 and min(b, c) == 1 or (b == 0 and min(a, c) == 1) or (c == 0 and min(a, b) == 1):
		print(2)
	elif a == 0 and min(b, c) > 1 or (b == 0 and min(a, c) > 1) or (c == 0 and min(a, b) > 1):
		print(3)
	elif a == b == 1 or b == c == 1 or a == c == 1:
		print(3)
	elif min(a, b, c) == 1 or a == b == c == 2:
		print(4)
	elif min(a, b, c) == 2:
		print(5)
	elif min(a, b, c) == 3:
		print(6)
	else:
		print(7)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
for _ in range(I()):
	(a, b, c) = R()
	m = -1
	for x1 in range(2):
		for x2 in range(2):
			for x3 in range(2):
				for x4 in range(2):
					for x5 in range(2):
						for x6 in range(2):
							for x7 in range(2):
								if x1 + x4 + x5 + x7 <= a and x2 + x4 + x6 + x7 <= b and (x3 + x5 + x6 + x7 <= c) and (x1 + x2 + x3 + x4 + x5 + x6 + x7 > m):
									m = x1 + x2 + x3 + x4 + x5 + x6 + x7
	print(m)


def test(x, d, j, p):
	d_test = x[0] + x[3] + x[5] + x[6]
	j_test = x[1] + x[3] + x[4] + x[6]
	p_test = x[2] + x[4] + x[5] + x[6]
	if d_test <= d and j_test <= j and (p_test <= p):
		return sum([i for i in x])
	return 0

def findMaxCustomers(i, mx, x, d, j, p):
	for k in range(2):
		x[i] = k
		if i == 6:
			mx = max(mx, test(x, d, j, p))
		else:
			mx = findMaxCustomers(i + 1, mx, x, d, j, p)
	return mx

def main():
	t = int(input())
	while t:
		x = [0] * 7
		mx = 0
		(d, j, p) = list(map(int, input().split()))
		if d > 4:
			d = 4
		if j > 4:
			j = 4
		if p > 4:
			p = 4
		mx = findMaxCustomers(0, mx, x, d, j, p)
		print(mx)
		t -= 1
main()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('../output.txt', 'w')
except:
	pass
for _ in range(int(input())):
	(a, b, c) = sorted(L())[::-1]
	ans = 0
	if a:
		a -= 1
		ans += 1
	if b:
		b -= 1
		ans += 1
	if c:
		c -= 1
		ans += 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)


for _ in range(int(input())):
	m = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	a = list(map(int, input().split()))
	a.sort()
	visitors = 0
	for i in m:
		if a[0] - i[0] >= 0 and a[1] - i[1] >= 0 and (a[2] - i[2] >= 0):
			visitors += 1
			a[0] -= i[0]
			a[1] -= i[1]
			a[2] -= i[2]
	print(visitors)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(a, b, c) = list(map(int, input().split()))
	s1 = [a, b, c]
	s1.sort(reverse=True)
	l = ['100', '010', '001', '110', '101', '011', '111']
	ans = 0
	for i in l:
		if int(i[0]) <= int(s1[0]) and int(i[1]) <= int(s1[1]) and (int(i[2]) <= int(s1[2])):
			s1[0] = s1[0] - int(i[0])
			s1[1] = s1[1] - int(i[1])
			s1[2] = s1[2] - int(i[2])
			ans = ans + 1
	print(ans)


n = int(input())
for _ in range(n):
	res = 0
	a = [int(x) for x in input().split()]
	a.sort()
	for i in range(3):
		if a[i] > 0:
			a[i] -= 1
			res += 1
	for (i, j) in ([1, 2], [0, 2], [0, 1]):
		if a[i] > 0 and a[j] > 0:
			a[i] -= 1
			a[j] -= 1
			res += 1
	if all((x > 0 for x in a)):
		res += 1
	print(res)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
tests = inp()
testcount = 0
while testcount < tests:
	count = 0
	arr = inlt()
	arr.sort()
	a = arr[0]
	b = arr[1]
	c = arr[2]
	for elem in arr:
		if elem > 0:
			elem -= 1
			count += 1
	if c > 1 and b > 1:
		c -= 1
		b -= 1
		count += 1
	if a > 1 and c > 1:
		a -= 1
		c -= 1
		count += 1
	if a > 1 and b > 1:
		a -= 1
		b -= 1
		count += 1
	if a > 1 and b > 1 and (c > 1):
		count += 1
	print(count)
	testcount += 1


t = int(input())
while t:
	t -= 1
	(a, b, c) = map(int, input().split())
	cus = 0
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		if a >= 1:
			a -= 1
			cus += 1
		if b >= 1:
			b -= 1
			cus += 1
		if c >= 1:
			c -= 1
			cus += 1
		l = []
		l.append(a)
		l.append(b)
		l.append(c)
		c1 = l.count(1)
		c0 = l.count(0)
		if c0 == 0:
			if c1 == 1 or c1 == 2:
				cus += 2
			elif c1 == 3:
				cus += 1
			else:
				a -= 2
				b -= 2
				c -= 2
				cus += 3
				if a >= 1 and b >= 1 and (c >= 1):
					cus += 1
		elif c0 == 1:
			cus += 1
		print(cus)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	(a, b, c) = sorted(value())
	ans = 0
	if c > 0:
		ans += 1
		c -= 1
	if b > 0:
		ans += 1
		b -= 1
	if a > 0:
		ans += 1
		a -= 1
	if c * b:
		ans += 1
		c -= 1
		b -= 1
	if a * b:
		ans += 1
		a -= 1
		b -= 1
	if a * c:
		ans += 1
		a -= 1
		c -= 1
	if a * b * c:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	M = max([a, b, c])
	m = min([a, b, c])
	if m >= 4:
		print(7)
	else:
		ans = 0
		(a, b, c) = (M, a + b + c - M - m, m)
		if a > 0:
			ans += 1
			a -= 1
		if b > 0:
			ans += 1
			b -= 1
		if c > 0:
			c -= 1
			ans += 1
		if a > 0 and b > 0:
			a -= 1
			b -= 1
			ans += 1
		if a > 0 and c > 0:
			a -= 1
			c -= 1
			ans += 1
		if b > 0 and c > 0:
			b -= 1
			c -= 1
			ans += 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		print(ans)


t = int(input())
for T in range(t):
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	a = x[0]
	b = x[1]
	c = x[2]
	subsets = [['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
	count = 0
	for i in subsets:
		if len(i) == 1:
			if i[0] == 'a' and a > 0:
				count += 1
				a -= 1
			elif i[0] == 'b' and b > 0:
				count += 1
				b -= 1
			elif i[0] == 'c' and c > 0:
				count += 1
				c -= 1
		if len(i) == 2:
			if 'a' in i and 'b' in i and (a > 0) and (b > 0):
				count += 1
				a -= 1
				b -= 1
			if 'a' in i and 'c' in i and (a > 0) and (c > 0):
				count += 1
				a -= 1
				c -= 1
			if 'c' in i and 'b' in i and (c > 0) and (b > 0):
				count += 1
				c -= 1
				b -= 1
		if len(i) == 3:
			if a > 0 and b > 0 and (c > 0):
				count += 1
				a -= 1
				b -= 1
				c -= 1
	print(count)


t = int(input())
while t > 0:
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	ans = 0
	for i in range(3):
		if a[i] > 0:
			a[i] -= 1
			ans += 1
	for i in range(3):
		try:
			if a[i] > 0 and a[i + 1] > 0:
				a[i] -= 1
				a[i + 1] -= 1
				ans += 1
			if a[i] > 0 and a[i + 2] > 0:
				a[i] -= 1
				a[i + 2] -= 1
				ans += 1
			if a[i] > 0 and a[i + 1] > 0 and (a[i + 2] > 0):
				a[i] -= 1
				a[i + 1] -= 1
				a[i + 2] -= 1
				ans += 1
		except:
			continue
	print(ans)
	t -= 1


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = a + b + c
	t = min(a, b, c)
	c = max(a, b, c)
	a = t
	b = s - (a + c)
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0:
		ans += 1
		b -= 1
		a -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


t = int(input())
answer = []
for kek in range(t):
	(a, b, c) = map(int, input().split())
	a = [a, b, c]
	a.sort()
	ans = 0
	for i in range(3):
		if a[i] > 0:
			a[i] -= 1
			ans += 1
	if a[2] > 0 and a[1] > 0:
		ans += 1
		a[2] -= 1
		a[1] -= 1
	if a[2] > 0 and a[0] > 0:
		ans += 1
		a[2] -= 1
		a[0] -= 1
	if a[1] > 0 and a[0] > 0:
		ans += 1
		a[1] -= 1
		a[0] -= 1
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		ans += 1
	answer.append(ans)
print(*answer, sep='\n')


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	ans = 0
	l = list(map(int, input().split()))
	l.sort()
	b = l[2]
	a = l[1]
	c = l[0]
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a > 0 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if b > 0 and c > 0:
		ans += 1
		c -= 1
		b -= 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)


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	count = 0
	for j in range(3):
		if l[j] >= 1:
			l[j] -= 1
			count += 1
	l.sort()
	if l[0] >= 1 and l[2] >= 1:
		count += 1
		l[0] -= 1
		l[2] -= 1
	if l[1] >= 1 and l[2] >= 1:
		count += 1
		l[1] -= 1
		l[2] -= 1
	if l[1] >= 1 and l[0] >= 1:
		count += 1
		l[1] -= 1
		l[0] -= 1
	if l[0] >= 1 and l[1] >= 1 and (l[2] >= 1):
		count += 1
	print(count)


t = int(input())
for i in range(t):
	a = [int(x) for x in input().split()]
	a.sort()
	if a.count(0) == 1:
		if a[1] == 1:
			print(2)
		else:
			print(3)
	elif a.count(0) == 2:
		print(1)
	elif a.count(0) == 3:
		print(0)
	elif a[0] == 1:
		if a[1] == 1:
			print(3)
		else:
			print(4)
	elif a[0] == 2:
		if a[1] == 2:
			if a[2] == 2:
				print(4)
			else:
				print(5)
		else:
			print(5)
	elif a[0] == 3:
		print(6)
	else:
		print(7)


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


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	cnt = 0
	if a:
		a -= 1
		cnt += 1
	if b:
		b -= 1
		cnt += 1
	if c:
		c -= 1
		cnt += 1
	mx = max(a, b, c)
	if mx == a:
		if a and b:
			a -= 1
			b -= 1
			cnt += 1
		if a and c:
			a -= 1
			c -= 1
			cnt += 1
		if b and c:
			b -= 1
			c -= 1
			cnt += 1
	elif mx == b:
		if a and b:
			a -= 1
			b -= 1
			cnt += 1
		if b and c:
			b -= 1
			c -= 1
			cnt += 1
		if a and c:
			a -= 1
			c -= 1
			cnt += 1
	else:
		if a and c:
			a -= 1
			c -= 1
			cnt += 1
		if b and c:
			b -= 1
			c -= 1
			cnt += 1
		if a and b:
			a -= 1
			b -= 1
			cnt += 1
	if a and b and c:
		a -= 1
		b -= 1
		c -= 1
		cnt += 1
	print(cnt)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	d = 0
	while l[0] > 0 or l[1] > 0 or l[2] > 0:
		if l[0] == 0 and l[1] == 0 and (l[2] > 0):
			d = d + 1
			break
		elif l[0] == 0 and l[1] == 1:
			d = d + 2
			break
		elif l[0] == 0 and l[1] > 1:
			d = d + 3
			break
		if l[0] > 0:
			l[0] -= 1
			l[1] -= 1
			l[2] -= 1
			d = d + 3
		if l[0] > 1 and l[1] > 1 and (l[2] > 1):
			d = d + 3
			l[0] -= 2
			break
		if l[0] == 1 and l[2] > 1:
			d = d + 2
			l[0] -= 1
			break
		if l[0] == 0 and l[1] > 0:
			d = d + 1
			break
		break
	if l[0] > 0:
		d = d + 1
	print(d)


for TS in range(int(input())):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	(a, b, c) = (l[0], l[1], l[2])
	ans = 0
	if a > 0:
		ans = ans + 1
		a -= 1
	if b > 0:
		ans = ans + 1
		b -= 1
	if c > 0:
		ans = ans + 1
		c -= 1
	if a > 0 and b > 0:
		ans = ans + 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans = ans + 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans = ans + 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ans = ans + 1
		a -= 1
		b -= 1
		c -= 1
	print(ans)


from operator import ge, sub
MASKS = [(0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
for __ in range(int(input())):
	a = tuple(sorted(map(int, input().split())))
	s = 0
	for m in MASKS:
		if all(map(ge, a, m)):
			a = tuple(map(sub, a, m))
			s += 1
	print(s)


import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('A.txt').readlines())

	def input():
		return next(f)
else:
	input = lambda : sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
import itertools
t = int(input())
combos = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
for _ in range(t):
	(a, b, c) = map(int, input().split())
	best = 0
	for i in itertools.product(*[[0, 1] for _ in range(7)]):
		res = [0, 0, 0]
		for (n, j) in enumerate(i):
			if j:
				for k in combos[n]:
					res[k] += 1
		if all([u >= v for (u, v) in zip([a, b, c], res)]):
			best = max(best, sum(i))
	print(best)


r = [['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]
s = []
t = int(input())
for ihh in range(0, t):
	x = input()
	xx = x.split()
	for i in range(0, 3):
		xx[i] = int(xx[i])
	xx.sort()
	xx.reverse()
	a = xx[0]
	b = xx[1]
	c = xx[2]
	g = 0
	for i in r:
		q = 0
		for j in i:
			if j == 'a' and a != 0:
				a -= 1
				q += 1
			elif j == 'b' and b != 0:
				b -= 1
				q += 1
			elif j == 'c' and c != 0:
				c -= 1
				q += 1
		if q == len(i):
			g += 1
	s.append(g)
for i in s:
	print(i)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	li = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 1)]
	count = 0
	res = (a, b, c)
	res = tuple(sorted(res, reverse=True))
	for i in range(7):
		res = tuple(map(lambda i, j: i - j, res, li[i]))
		(x, y, z) = res
		if not (x < 0 or y < 0 or z < 0):
			count += 1
		else:
			res = tuple(map(lambda i, j: i + j, res, li[i]))
	print(count)


import sys, math, itertools, collections, bisect
input = lambda : sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10 ** 9 + 7
mans = inf
ans = 0
count = 0
pro = 1

def solve():
	count = 0
	ABC = list(map(int, input().split()))
	for (i, ai) in enumerate(ABC):
		if ai >= 1:
			count += 1
			ABC[i] -= 1
	ABC.sort(reverse=1)
	if ABC[0] and ABC[1]:
		ABC[0] -= 1
		ABC[1] -= 1
		count += 1
	if ABC[2] and ABC[0]:
		ABC[2] -= 1
		ABC[0] -= 1
		count += 1
	if ABC[1] and ABC[2]:
		ABC[1] -= 1
		ABC[2] -= 1
		count += 1
	if ABC[0] and ABC[2] and ABC[1]:
		ABC[0] -= 1
		ABC[2] -= 1
		ABC[1] -= 1
		count += 1
	print(count)
t = int(input())
for i in range(t):
	solve()


n = int(input())
cases = [list(map(int, input().split())) for i in range(n)]
pattern = [[0, 0, 0] for i in range(7)]
for i in range(1, 8):
	cnt = 0
	j = i
	while j > 0:
		b = j % 2
		j //= 2
		pattern[i - 1][cnt] = b
		cnt += 1

def judge(a, b, c, d):
	for i in range(1, 2 ** 7):
		curd = 0
		cnt = 0
		ta = a
		tb = b
		tc = c
		j = i
		while j > 0:
			bit = j % 2
			if bit == 1:
				(da, db, dc) = pattern[cnt]
				ta = ta - da
				tb = tb - db
				tc = tc - dc
				curd += 1
			cnt += 1
			j //= 2
		if ta >= 0 and tb >= 0 and (tc >= 0) and (d == curd):
			return True
	return False
for (a, b, c) in cases:
	for i in range(7):
		if judge(a, b, c, 7 - i):
			print(7 - i)
			break
	else:
		print(0)


import os
import sys
from io import BytesIO, IOBase

def solution(a, b, c):
	if a == 0 and b == 0 and (c == 0):
		print(0)
		return
	res = 0
	comb = ['001', '010', '100', '011', '101', '110', '111']
	comb2 = ['01', '10', '11']
	(a, b, c) = sorted([a, b, c])
	if a == 0 and b == 0:
		print(1)
		return
	if a == 0:
		for co in comb2:
			(bb, cc) = map(int, co)
			b -= bb
			c -= cc
			if b < 0 or c < 0:
				break
			res += 1
	else:
		for co in comb:
			(aa, bb, cc) = map(int, co)
			a -= aa
			b -= bb
			c -= cc
			if a < 0 or b < 0 or c < 0:
				break
			res += 1
	print(res)

def main():
	for _ in range(int(input())):
		(a, b, c) = [int(x) for x in input().split()]
		solution(a, b, c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve():
	ans = 0
	(a, b, c) = map(int, input().split())
	if a:
		ans += 1
		a -= 1
	if b:
		ans += 1
		b -= 1
	if c:
		ans += 1
		c -= 1
	(a, b, c) = sorted([a, b, c])
	if c and b:
		ans += 1
		b -= 1
		c -= 1
	if c and a:
		ans += 1
		a -= 1
		c -= 1
	if a and b:
		ans += 1
		a -= 1
		b -= 1
	if a and b and c:
		ans += 1
	print(ans)
t = int(input())
for i in range(t):
	solve()


import itertools
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	tuples = list(itertools.product([0, 1], repeat=3))
	tuples.remove((0, 0, 0))
	for n in range(8, 0, -1):
		for p in itertools.combinations(range(7), n):
			pa = pb = pc = 0
			for i in p:
				pa += tuples[i][0]
				pb += tuples[i][1]
				pc += tuples[i][2]
			if pa <= a and pb <= b and (pc <= c):
				break
		else:
			continue
		break
	else:
		n = 0
	print(n)


l = ['a', 'b', 'c', 'ab', 'ac', 'bc', 'abc']

def f(arr, var):
	global l, ans, a, b, c
	if var == len(l):
		x = y = z = 0
		for i in arr:
			for j in i:
				if j == 'a':
					x += 1
				if j == 'b':
					y += 1
				if j == 'c':
					z += 1
		if x > a or y > b or z > c:
			return
		ans = max(ans, len(arr))
		return
	arr.append(l[var])
	f(arr, var + 1)
	arr.pop()
	f(arr, var + 1)
t = int(input())
for _ in range(t):
	ans = 0
	(a, b, c) = map(int, input().split())
	var = 0
	f([], var)
	print(ans)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	res = 0
	for i in range(3):
		if a[i]:
			a[i] -= 1
			res += 1
	for i in range(3):
		for j in range(i + 1, 3):
			if a[i] and a[j]:
				a[i] -= 1
				a[j] -= 1
				res += 1
	if a[0] and a[1] and a[2]:
		res += 1
	print(res)


def f(a, b, c, combos, i):
	if i == len(combos):
		return 0
	(na, nb, nc) = (a - combos[i][0], b - combos[i][1], c - combos[i][2])
	ans = -float('inf')
	if na >= 0 and nb >= 0 and (nc >= 0):
		ans = max(1 + f(na, nb, nc, combos, i + 1), f(a, b, c, combos, i + 1))
	else:
		ans = f(a, b, c, combos, i + 1)
	return ans
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	combos = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
	print(f(a, b, c, combos, 0))


from sys import stdin, stdout
l2 = ['100', '010', '001', '110', '101', '011', '111']
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ans = 0
	for i in range(7):
		l1 = list(map(int, list(l2[i])))
		f = 0
		for i in range(3):
			if l1[i] == 1 and l[i] == 0:
				f = 1
				break
		if f == 0:
			ans += 1
			for i in range(3):
				if l1[i] == 1:
					l[i] -= 1
	print(ans)


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


t = int(input())
while t > 0:
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = 0
	if a > 0:
		a -= 1
		n += 1
	if b > 0:
		b -= 1
		n += 1
	if c > 0:
		c -= 1
		n += 1
	if b > a:
		d = a
		a = b
		b = d
	if c > a:
		d = a
		a = c
		c = d
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		n += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		n += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		n += 1
	if a > 0 and b > 0 and (c > 0):
		n += 1
	print(n)
	t -= 1


n = int(input())
rows = []
for i in range(n):
	row = input().split(' ')
	row = [int(row[x]) for x in range(3)]
	row.sort(reverse=True)
	rows.append(row)
for i in range(n):
	y = 0
	for j in range(3):
		if int(rows[i][j]) > 0:
			y = y + 1
			rows[i][j] = int(rows[i][j]) - 1
	for j in range(3):
		for k in range(3):
			if j < k:
				if int(rows[i][j]) > 0 and int(rows[i][k]) > 0:
					y = y + 1
					rows[i][j] = int(rows[i][j]) - 1
					rows[i][k] = int(rows[i][k]) - 1
	if int(rows[i][0]) > 0 and int(rows[i][1]) > 0 and (int(rows[i][2]) > 0):
		y = y + 1
	print(y)


in1 = int(input())
for _ in range(in1):
	in2 = []
	in2 = list(map(int, input().split()))
	in2.sort()
	ans = 0
	for i in range(len(in2)):
		if in2[i] > 0:
			in2[i] -= 1
			ans += 1
	if in2[0] > 0 and in2[2] > 0:
		in2[0] -= 1
		in2[2] -= 1
		ans += 1
	if in2[1] > 0 and in2[2] > 0:
		in2[1] -= 1
		in2[2] -= 1
		ans += 1
	if in2[0] > 0 and in2[1] > 0:
		in2[0] -= 1
		in2[1] -= 1
		ans += 1
	if in2[0] > 0 and in2[1] > 0 and (in2[2] > 0):
		in2[0] -= 1
		in2[1] -= 1
		in2[2] -= 1
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(c, b, a) = sorted([int(x) for x in input().split()])
	count = 0
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	if a > 0 and b > 0:
		count += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		count += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		count += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)


import sys
from itertools import combinations
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		foods = list(map(int, sys.stdin.readline().split()))
		e = list(enumerate(foods))
		e.sort(key=lambda x: -x[1])
		div = []
		comb = []
		res = 0
		for i in range(3):
			div.append(e[i][0])
		for i in range(1, 4):
			comb.extend(list(combinations(div, i)))
		for i in range(len(comb)):
			bool = True
			for j in range(len(comb[i])):
				if foods[comb[i][j]] <= 0:
					bool = False
					break
			if bool:
				for k in range(len(comb[i])):
					foods[comb[i][k]] -= 1
				res += 1
		print(res)
main()


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ret = 0
	if a > 0:
		ret += 1
		a -= 1
	if b > 0:
		ret += 1
		b -= 1
	if c > 0:
		ret += 1
		c -= 1
	if a > 1 and b == 1 and (c == 1):
		ret += 2
		a -= 2
		b -= 1
		c -= 1
	if b > 1 and a == 1 and (c == 1):
		ret += 2
		b -= 2
		a -= 1
		c -= 1
	if c > 1 and a == 1 and (b == 1):
		ret += 2
		c -= 2
		a -= 1
		b -= 1
	if a > 0 and b > 0:
		ret += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ret += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ret += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ret += 1
		a -= 1
		b -= 1
		c -= 1
	print(ret)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	count = 0
	if a >= 1:
		count += 1
		a -= 1
	if b >= 1:
		count += 1
		b -= 1
	if c >= 1:
		count += 1
		c -= 1
	k = [a, b, c]
	k.sort()
	if k[1] == 0:
		print(count)
	elif k[0] == 0:
		print(count + 1)
	elif k[1] > k[0]:
		k[1] = k[0] + 1
		k[2] = k[1]
		print(min(7, count + 1 + k[0]))
	elif k[2] > k[1]:
		k[2] = k[1] + 1
		print(min(7, count + k[2]))
	elif k[0] == 1:
		print(count + 1)
	elif k[0] == 2:
		print(count + 3)
	else:
		print('7')


for _ in range(int(input())):
	(a, b, c) = map(int, input().strip().split())
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	if max(a, b, c) == c:
		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:
			ans += 1
			a -= 1
			b -= 1
	elif max(a, b, c) == b:
		if b > 0 and c > 0:
			ans += 1
			b -= 1
			c -= 1
		if a > 0 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			ans += 1
			a -= 1
			c -= 1
	elif max(a, b, c) == a:
		if a > 0 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			ans += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			ans += 1
			b -= 1
			c -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(A, B, C) = [int(x) for x in input().split()]
		ans = 0
		if A >= 1:
			ans += 1
			A -= 1
		if B >= 1:
			ans += 1
			B -= 1
		if C >= 1:
			ans += 1
			C -= 1
		if A >= B and A >= C:
			if A >= 1 and B >= 1:
				ans += 1
				A -= 1
				B -= 1
			if A >= 1 and C >= 1:
				ans += 1
				A -= 1
				C -= 1
			if B >= 1 and C >= 1:
				ans += 1
				B -= 1
				C -= 1
		elif C >= B and C >= A:
			if C >= 1 and B >= 1:
				ans += 1
				C -= 1
				B -= 1
			if A >= 1 and C >= 1:
				ans += 1
				A -= 1
				C -= 1
			if B >= 1 and A >= 1:
				ans += 1
				B -= 1
				A -= 1
		elif B >= C and B >= A:
			if C >= 1 and B >= 1:
				ans += 1
				C -= 1
				B -= 1
			if A >= 1 and B >= 1:
				ans += 1
				A -= 1
				B -= 1
			if C >= 1 and A >= 1:
				ans += 1
				C -= 1
				A -= 1
		if A >= 1 and B >= 1 and (C >= 1):
			ans += 1
			A -= 1
			B -= 1
			C -= 1
		print(ans)
main()


t = int(input())
for _ in range(t):
	q = list(map(int, input().split()))
	q.sort(reverse=True)
	ans = 0
	for i in sorted(list(range(1, 1 << 3)), key=lambda x: bin(x).count('1')):
		p = [0] * 3
		for j in range(3):
			if i & 1:
				if q[j] == 0:
					break
				p[j] = 1
			i >>= 1
		else:
			ans += 1
			for j in range(3):
				q[j] -= p[j]
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def solve(arr, a, b, c):
	ans = 0
	for i in arr:
		if i == 1:
			if a > 0:
				a -= 1
				ans += 1
		if i == 2:
			if b > 0:
				b -= 1
				ans += 1
		if i == 3:
			if c > 0:
				c -= 1
				ans += 1
		if i == 4:
			if a > 0 and b > 0:
				a -= 1
				b -= 1
				ans += 1
		if i == 5:
			if a > 0 and c > 0:
				a -= 1
				c -= 1
				ans += 1
		if i == 6:
			if b > 0 and c > 0:
				b -= 1
				c -= 1
				ans += 1
		if i == 7:
			if a > 0 and b > 0 and (c > 0):
				a -= 1
				b -= 1
				c -= 1
				ans += 1
	return ans
t = ip()
for _ in range(t):
	(a, b, c) = inp()
	ans = 0
	step = [i for i in range(1, 8)]
	step = list(permutations(step))
	ans = -1
	for i in step:
		ans = max(ans, solve(i, int(a), int(b), int(c)))
	out(ans)


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	cnt = 0
	maxx = max(a, b, c)
	minn = min(a, b, c)
	med = a + b + c - maxx - minn
	a = maxx
	b = med
	c = minn
	if a > 0:
		a -= 1
		cnt += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		cnt += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		cnt += 1
	if b > 0:
		b -= 1
		cnt += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		cnt += 1
	if c > 0:
		c -= 1
		cnt += 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
	print(cnt)


for _ in range(int(input())):
	ans = 0
	A = [0, 1]
	(a, b, c) = map(int, input().split())
	for i1 in A:
		for i2 in A:
			for i3 in A:
				for i4 in A:
					for i5 in A:
						for i6 in A:
							for i7 in A:
								if i1 + i5 + i6 + i7 <= a and i2 + i4 + i6 + i7 <= b and (i3 + i4 + i5 + i7 <= c):
									ans = max(ans, i1 + i2 + i3 + i4 + i5 + i6 + i7)
	print(ans)


t = int(input())
for i in range(t):
	zi = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [0, 1, 1], [1, 1, 1], [1, 0, 1]]
	ti = list(map(int, input().split()))
	ti.sort(reverse=True)
	out = 0
	for i in range(7):
		if ti[0] - zi[i][0] >= 0 and ti[1] - zi[i][1] >= 0 and (ti[2] - zi[i][2] >= 0):
			ti[0] = ti[0] - zi[i][0]
			ti[1] = ti[1] - zi[i][1]
			ti[2] = ti[2] - zi[i][2]
			out += 1
	print(out)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a == 0 and b == 0 and (c == 0):
		print(0)
	elif a == 0 and b == 0 and (c != 0) or (b == 0 and c == 0 and (a != 0)) or (a == 0 and c == 0 and (b != 0)):
		print(1)
	elif a == 0 and b * c != 0 or (b == 0 and a * c != 0) or (c == 0 and b * a != 0):
		arr = [a, b, c]
		arr.sort()
		if min(arr[1:]) == 1:
			print(2)
		else:
			print(3)
	elif a * b * c != 0:
		arr = [a, b, c]
		arr.sort()
		if arr[0] >= 4:
			print(7)
		else:
			arr = [a, b, c]
			arr.sort()
			if arr[0] >= 3:
				print(6)
			elif arr[0] >= 2:
				if arr.count(2) == 3:
					print(4)
				else:
					print(5)
			elif arr[0] >= 1:
				if arr.count(1) >= 2:
					print(3)
				else:
					print(4)


t = int(input())
for z in range(t):
	x = [int(i) for i in input().split()]
	a = x[0]
	b = x[1]
	c = x[2]
	if c > a:
		(a, c) = (c, a)
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 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)


t = int(input())
for w in range(t):
	arr = list(map(int, input().strip().split()))
	i = j = k = m = 0
	for p in arr:
		if p > 0:
			i += 1
		if p > 1:
			j += 1
		if p > 2:
			k += 1
		if p > 3:
			m += 1
	s = i
	if j <= 1:
		print(s)
	elif j == 2:
		print(s + 1)
	elif k == 0:
		print(s + 1)
	elif k <= 2:
		print(s + 2)
	else:
		print(s + 3 + (m >= 3))


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(1000000000.0 + 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


def solve():
	dishes = list(map(int, input().split()))
	count = 0
	if dishes[0] >= 4 and dishes[1] >= 4 and (dishes[2] >= 4):
		print(7)
		return
	(a, b, c) = list(sorted(dishes))
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	(a, b, c) = list(sorted([a, b, c], reverse=True))
	if b > 0:
		a -= 1
		b -= 1
		count += 1
	if c > 0 and a > 0:
		a -= 1
		c -= 1
		count += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		count += 1
	if a > 0 and b > 0 and (c > 0):
		a -= 1
		b -= 1
		c -= 1
		count += 1
	print(count)
T = int(input())
for _ in range(T):
	solve()


from pprint import pprint
q = int(input())
for _ in range(q):
	(a, b, c) = map(int, input().split())
	menu = []
	menu.append([0, 0, 1])
	menu.append([0, 1, 0])
	menu.append([1, 0, 0])
	menu.append([0, 1, 1])
	menu.append([1, 0, 1])
	menu.append([1, 1, 0])
	menu.append([1, 1, 1])
	import itertools
	res = 0
	for pat in list(itertools.permutations(menu)):
		(x, y, z) = (a, b, c)
		tres = 0
		for (xx, yy, zz) in pat:
			(x, y, z) = (x - xx, y - yy, z - zz)
			if x >= 0 and y >= 0 and (z >= 0):
				tres += 1
		res = max(res, tres)
	print(res)


t = int(input())
for i in range(t):
	c = 0
	l = list(map(int, input().split()))
	l.sort()
	if l[0] >= 4:
		print(7)
		continue
	for j in range(3):
		if l[j] != 0:
			l[j] -= 1
			c += 1
	if l[0] == 0 and l[1] > 0:
		c += 1
	elif l[0] == 1 and l[2] > 1:
		c += 2
	elif l[0] == 2:
		c += 3
	elif l[0] == 1 and l[2] == 1:
		c += 1
	print(c)


def solve():
	(a, b, c) = map(int, input().split())
	s = [1, 2, 4, 6, 5, 3, 7]
	ans = 0
	(a, b, c) = sorted([a, b, c], reverse=True)
	for i in s:
		d = bin(i)[2:].rjust(3, '0')
		a1 = b1 = c1 = 0
		if d[0] == '1':
			a1 += 1
		if d[1] == '1':
			b1 += 1
		if d[2] == '1':
			c1 += 1
		if a1 > a or b1 > b or c1 > c:
			continue
		a -= a1
		b -= b1
		c -= c1
		ans += 1
	print(ans)
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	cnt = 0
	if l[0] > 0:
		cnt = cnt + 1
		l[0] = l[0] - 1
	if l[1] > 0:
		cnt = cnt + 1
		l[1] = l[1] - 1
	if l[2] > 0:
		cnt = cnt + 1
		l[2] = l[2] - 1
	if l[2] > 0 and l[1] > 0:
		l[2] = l[2] - 1
		l[1] = l[1] - 1
		cnt = cnt + 1
	if l[2] > 0 and l[0] > 0:
		l[2] = l[2] - 1
		l[0] = l[0] - 1
		cnt = cnt + 1
	if l[1] > 0 and l[0] > 0:
		l[1] = l[1] - 1
		l[0] = l[0] - 1
		cnt = cnt + 1
	if l[2] > 0 and l[1] > 0 and (l[0] > 0):
		cnt = cnt + 1
		l[2] = l[2] - 1
		l[1] = l[1] - 1
		l[0] = l[0] - 1
	print(cnt)


for _ in range(int(input())):
	(a1, b1, c1) = map(int, input().split())
	j = 0
	a = max(a1, b1, c1)
	c = min(a1, b1, c1)
	b = a1 + b1 + c1 - a - c
	if a != 0:
		j += 1
		a -= 1
	if b != 0:
		j += 1
		b -= 1
	if c != 0:
		j += 1
		c -= 1
	if a != 0 and b != 0:
		a -= 1
		b -= 1
		j += 1
	if a != 0 and c != 0:
		a -= 1
		c -= 1
		j += 1
	if b != 0 and c != 0:
		b -= 1
		c -= 1
		j += 1
	if a != 0 and b != 0 and (c != 0):
		j += 1
	print(j)


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


from sys import stdin
input = iter(stdin.readlines()).__next__

def visitors(a, b, c):
	if a == 0:
		if b == 0 and c == 0:
			return 0
		if b == 0 or c == 0:
			return 1
		if b >= 2 and c >= 2:
			return 3
		return 2
	if a == 1:
		return 1 + visitors(0, b, c)
	if a == 2:
		if b == 2 and c == 2:
			return 4
		return 5
	if a == 3:
		return 6
	return 7
t = int(input())
for _ in range(t):
	(a, b, c) = sorted(map(int, input().split()))
	print(visitors(a, b, c))


t = int(input())
while t:
	t -= 1
	arr = 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)


n = int(input())
for i in range(n):
	dishes = sorted(list(map(int, input().split())), reverse=True)
	counter = 0
	while any(dishes) > 0:
		for x in range(len(dishes)):
			if dishes[x] > 0:
				dishes[x] -= 1
				counter += 1
		for j in range(1, len(dishes)):
			if dishes[j] > 0 and dishes[j - 1] > 0:
				dishes[j] -= 1
				dishes[j - 1] -= 1
				counter += 1
		if dishes[0] > 0 and dishes[2] > 0:
			dishes[0] -= 1
			dishes[2] -= 1
			counter += 1
		if all(dishes) > 0:
			counter += 1
		break
	print(counter)


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		ret = 0
		if a > 0:
			ret += 1
			a -= 1
		if b > 0:
			ret += 1
			b -= 1
		if c > 0:
			ret += 1
			c -= 1
		if a > 1 and b == 1 and (c == 1):
			ret += 2
			a -= 2
			b -= 1
			c -= 1
		if b > 1 and a == 1 and (c == 1):
			ret += 2
			b -= 2
			a -= 1
			c -= 1
		if c > 1 and a == 1 and (b == 1):
			ret += 2
			c -= 2
			a -= 1
			b -= 1
		if a > 0 and b > 0:
			ret += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			ret += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			ret += 1
			b -= 1
			c -= 1
		if a > 0 and b > 0 and (c > 0):
			ret += 1
		print(ret)
main()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	hash_a = {}
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		ans = 0
		if a > 0:
			ans += 1
			a -= 1
		if b > 0:
			ans += 1
			b -= 1
		if c > 0:
			ans += 1
			c -= 1
		mx = max(a, b, c)
		if mx == a:
			if a > 0 and b > 0 and (not hash_a.get('ab')):
				ans += 1
				a -= 1
				b -= 1
				hash_a['ab'] = 1
			if a > 0 and c > 0 and (not hash_a.get('ac')):
				ans += 1
				a -= 1
				c -= 1
				hash_a['ac'] = 1
		elif mx == b:
			if b > 0 and c > 0 and (not hash_a.get('bc')):
				ans += 1
				b -= 1
				c -= 1
				hash_a['bc'] = 1
			if a > 0 and b > 0 and (not hash_a.get('ab')):
				ans += 1
				a -= 1
				b -= 1
				hash_a['ab'] = 1
		elif mx == c:
			if b > 0 and c > 0 and (not hash_a.get('bc')):
				ans += 1
				b -= 1
				c -= 1
				hash_a['bc'] = 1
			if a > 0 and c > 0 and (not hash_a.get('ac')):
				ans += 1
				a -= 1
				c -= 1
				hash_a['ac'] = 1
		if b > 0 and c > 0 and (not hash_a.get('bc')):
			ans += 1
			b -= 1
			c -= 1
			hash_a['bc'] = 1
		elif a > 0 and c > 0 and (not hash_a.get('ac')):
			ans += 1
			a -= 1
			c -= 1
			hash_a['ac'] = 1
		elif a > 0 and b > 0 and (not hash_a.get('ab')):
			ans += 1
			b -= 1
			a -= 1
			hash_a['ab'] = 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
			a -= 1
			b -= 1
			c -= 1
		print(ans)


for i in range(int(input())):
	l1 = list(map(int, input().split()))
	count = 0
	if l1[0] > 0:
		l1[0] -= 1
		count += 1
	if l1[1] > 0:
		l1[1] -= 1
		count += 1
	if l1[2] > 0:
		l1[2] -= 1
		count += 1
	c0 = 0
	for j in range(3):
		if l1[j] == 0:
			c0 += 1
	if c0 == 1:
		print(count + 1)
		continue
	elif c0 >= 2:
		print(count)
		continue
	c1 = 0
	for j in range(3):
		if l1[j] == 1:
			c1 += 1
	if c1 == 1 or c1 == 2:
		print(count + 2)
		continue
	elif c1 == 3:
		print(count + 1)
	elif c1 == 0:
		if l1[0] >= 3 and l1[1] >= 3 and (l1[2] >= 3):
			print(count + 4)
		else:
			print(count + 3)


for q in range(int(input())):
	x = list(map(int, input().split()))
	g = sorted(x, reverse=True)
	s = 0
	if g[0] == 0:
		print(0)
	elif g[0] == 1 or (g[0] > 1 and (g[1] == 1 or g[1] == 0)):
		for i in range(3):
			if g[i] >= 1:
				s = s + 1
		print(s)
	elif g[0] == 2 and g[2] == 2:
		print(4)
	elif g[2] >= 4:
		print(7)
	elif g[2] == 3:
		print(6)
	elif g[0] == 2 and g[1] == 1:
		print(2 + g[2])
	elif g[0] == 2 and g[1] == 2:
		print(3 + g[2])
	elif g[0] == 3 and g[2] == 2:
		print(5)
	elif g[0] == 3 and g[1] >= 2:
		print(3 + g[2])
	elif g[0] == 3 and g[1] == 1:
		print(2 + g[2])
	elif g[0] >= 4 and g[2] == 2:
		print(5)
	elif g[0] >= 4 and g[1] >= 2:
		print(3 + g[2])
	elif g[0] >= 4:
		print(1 + g[1] + g[2])


t = int(input())
for cnt in range(t):
	L = list(map(int, input().split()))
	L.sort()
	if L[0] == 0:
		if L[2] == 0:
			print(0)
		elif L[1] == 0:
			print(1)
		elif L[1] == 1:
			print(2)
		else:
			print(3)
		continue
	elif L[0] == 1:
		if L[1] == 1:
			print(3)
		else:
			print(4)
		continue
	elif L[0] == 2:
		if L[2] == 2:
			print(4)
		else:
			print(5)
		continue
	elif L[0] == 3:
		print(6)
	else:
		print(7)


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c) = map(int, input().split())
	s = a + b + c
	customer = 0
	a = max(a, b, c)
	c = min(a, b, c)
	b = s - a - c
	if a > 0:
		a -= 1
		customer += 1
	if b > 0:
		b -= 1
		customer += 1
	if c > 0:
		c -= 1
		customer += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		customer += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		customer += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		customer += 1
	if a > 0 and b > 0 and (c > 0):
		customer += 1
	print(customer)


from math import *
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	if a > 4:
		a = 4
	if b > 4:
		b = 4
	if c > 4:
		c = 4
	q = []
	q.append(a)
	q.append(b)
	q.append(c)
	q.sort()
	a = q[0]
	b = q[1]
	c = q[2]
	if c == 0:
		print(0)
	elif a == 0:
		print(min(b + 1, 3))
	elif a == 1:
		print(min(b + 2, 4))
	elif a == 2:
		if c == 2:
			print(4)
		else:
			print(5)
	elif a == 3:
		print(6)
	else:
		print(7)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	for _ in range(int(input())):
		arr = [int(i) for i in input().split()]
		arr.sort(reverse=True)
		counter = 0
		for i in range(3):
			if arr[i] > 0:
				arr[i] -= 1
				counter += 1
			if arr[i] > 0 and arr[(i + 1) % 3] > 0:
				counter += 1
				arr[i] -= 1
				arr[(i + 1) % 3] -= 1
		if min(arr) > 0:
			counter += 1
		print(counter)
solution()


def count(a, b, c):
	ans = 0
	if a == 0:
		if b == 0:
			if c != 0:
				ans += 1
		else:
			b = b - 1
			c = c - 1
			ans += 2
			if b > 0:
				ans += 1
	elif a != 0:
		a = a - 1
		b = b - 1
		c = c - 1
		ans += 3
		if a > 0:
			if c >= 2:
				ans += 2
				c = c - 2
				b = b - 1
				a = a - 1
				if a > 0:
					ans += 1
					a = a - 1
					b = b - 1
					if a > 0:
						ans += 1
			else:
				ans += 1
		elif b > 0:
			ans += 1
	return ans
q = int(input())
for _ in range(q):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	if c == 0:
		print(0)
	else:
		ans = count(a, b, c)
		print(ans)


R = lambda : map(int, input().split())
(t,) = R()
for _ in range(t):
	(x, y, z) = sorted(R())
	s = str(min(x, 4)) + str(min(y, 4)) + str(min(z, 4))
	l = ['001', '011', '022', '122', '223', '333', '444', '445']
	for i in range(8):
		if s < l[i]:
			print(i)
			break


for _ in range(int(input())):
	ls = sorted([int(x) for x in input().split()], reverse=True)
	res = 0
	for ind in range(3):
		if ls[ind] > 0:
			ls[ind] -= 1
			res += 1
	if ls[0] >= 1 and ls[1] >= 1:
		ls[0] -= 1
		ls[1] -= 1
		res += 1
	if ls[1] >= 1 and ls[2] >= 1:
		ls[1] -= 1
		ls[2] -= 1
		res += 1
	if ls[0] >= 1 and ls[2] >= 1:
		ls[0] -= 1
		ls[2] -= 1
		res += 1
	if sum((i > 0 for i in ls)) == 3:
		res += 1
	print(res)


t = int(input())
for _ in range(t):
	v = sorted([int(x) for x in input().split()], reverse=True)
	cnt = 0
	(a, b, c) = (v[0], v[1], v[2])
	if a:
		a -= 1
		cnt += 1
	if b:
		b -= 1
		cnt += 1
	if c:
		c -= 1
		cnt += 1
	if a and b:
		cnt += 1
		a -= 1
		b -= 1
	if a and c:
		cnt += 1
		a -= 1
		c -= 1
	if b and c:
		cnt += 1
		b -= 1
		c -= 1
	if a and b and c:
		cnt += 1
		a -= 1
		b -= 1
		c -= 1
	print(cnt)


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ans = 0
	n = 1
	while n < 8 and l[0] + l[1] + l[2] > 0:
		flag = True
		for i in range(3):
			if n & 2 ** i and (not l[i]):
				flag = False
				break
		for i in range(3):
			if flag and n & 2 ** i:
				l[i] -= 1
		if flag:
			ans += 1
		n += 1
	print(ans)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a >= 4 and b >= 4 and (c >= 4):
		print('7')
	else:
		lis = [a, b, c]
		res = 0
		lis.sort(reverse=True)
		if lis[0] > 0:
			lis[0] -= 1
			res += 1
		if lis[1] > 0:
			lis[1] -= 1
			res += 1
		if lis[2] > 0:
			lis[2] -= 1
			res += 1
		lis.sort(reverse=True)
		if lis[0] > 0 and lis[1] > 0:
			lis[0] -= 1
			lis[1] -= 1
			res += 1
		if lis[1] > 0 and lis[2] > 0:
			lis[1] -= 1
			lis[2] -= 1
			res += 1
		if lis[0] > 0 and lis[2] > 0:
			lis[0] -= 1
			lis[2] -= 1
			res += 1
		if lis[0] > 0 and lis[1] > 0 and (lis[2] > 0):
			res += 1
		print(res)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	count = 0
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	for i in range(len(l)):
		if l[i] >= 1:
			count += 1
			l[i] -= 1
	l.sort()
	if l[0] == 0 and l[1] >= 1:
		count += 1
	elif l[0] != 0:
		if l[0] == 2:
			count += 3
		elif l[0] > 2:
			count += 4
		elif l[0] == 1 and l[1] > 1:
			count += 2
		elif l[0] == 1 and l[1] == 1 and (l[2] == 1):
			count += 1
		elif l[0] == 1 and l[1] == 1 and (l[2] > 1):
			count += 2
	print(count)


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


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	d = sorted(li())
	(a, b, c) = tuple(d)
	r = 0
	for i in range(2):
		for j in range(2):
			for k in range(2):
				if a >= i and b >= j and (c >= k):
					r += 1
					(a, b, c) = (a - i, b - j, c - k)
	print(r - 1)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()), reverse=True)
	trigger = 5
	r = 0
	if a > 0:
		a -= 1
		r += 1
	if b > 0:
		b -= 1
		r += 1
	if c > 0:
		c -= 1
		r += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		r += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		r += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		r += 1
	if a > 0 and b > 0 and (c > 0):
		r += 1
	print(r)


def display_max_visitors(dishes):
	truth_table = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
	dishes.sort(reverse=True)
	no_of_visitors = 0
	for combo in truth_table:
		dishes = [d - c for (d, c) in zip(dishes, combo)]
		if -1 in dishes:
			dishes = [d + c for (d, c) in zip(dishes, combo)]
		else:
			no_of_visitors += 1
	print(no_of_visitors)

def main():
	trials = int(input())
	for _ in range(trials):
		dishes = list(map(int, input().split()))
		display_max_visitors(dishes)
main()


t = int(input())
a = []
for i in range(t):
	b = list(map(int, input().split()))
	a.append(b)
for i in a:
	a = i[0]
	b = i[1]
	c = i[2]
	t = 0
	if a > 0:
		t += 1
		a += -1
	if b > 0:
		t += 1
		b += -1
	if c > 0:
		t += 1
		c += -1
	k = max(a, b, c)
	q = min(a, b, c)
	if a == k and c == q:
		l = b
	if b == k and c == q:
		l = a
	if c == k and b == q:
		l = a
	if a == k and b == q:
		l = c
	if b == k and a == q:
		l = c
	if c == k and a == q:
		l = b
	if k > 0 and l > 0:
		t += 1
		k += -1
		l += -1
	if k > 0 and q > 0:
		t += 1
		k += -1
		q += -1
	if q > 0 and l > 0:
		t += 1
		l += -1
		q += -1
	if k > 0 and q > 0 and (l > 0):
		t += 1
	print(t)


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)


n = int(input())
for n in range(n):
	data = list(map(int, input().strip().split()))
	c = 0
	data.sort(reverse=True)
	if data[0] >= 1:
		data[0] -= 1
		c += 1
	if data[1] >= 1:
		data[1] -= 1
		c += 1
	if data[2] >= 1:
		data[2] -= 1
		c += 1
	if data[0] >= 1 and data[1] >= 1:
		data[0] -= 1
		data[1] -= 1
		c += 1
	if data[1] >= 1 and data[2] >= 1:
		data[1] -= 1
		data[2] -= 1
		c += 1
	if data[0] >= 1 and data[2] >= 1:
		data[0] -= 1
		data[2] -= 1
		c += 1
	if data[0] >= 1 and data[1] >= 1 and (data[2] >= 1):
		c += 1
	print(c)


def one(arr):
	count = 0
	for i in range(len(arr)):
		if arr[i] > 0:
			arr[i] -= 1
			count += 1
	return (count, arr)

def two(arr, count):
	mn = max(arr)
	if mn == 0:
		return count
	if mn == arr[0]:
		if arr[1] > 0:
			arr[0] -= 1
			arr[1] -= 1
			count += 1
		if arr[0] > 0 and arr[2] > 0:
			arr[0] -= 1
			arr[2] -= 1
			count += 1
		if arr[1] > 0 and arr[2] > 0:
			arr[1] -= 1
			arr[2] -= 1
			count += 1
		return (count, arr)
	elif mn == arr[1]:
		if arr[0] > 0:
			arr[0] -= 1
			arr[1] -= 1
			count += 1
		if arr[1] > 0 and arr[2] > 0:
			arr[1] -= 1
			arr[2] -= 1
			count += 1
		if arr[0] > 0 and arr[2] > 0:
			arr[0] -= 1
			arr[2] -= 1
			count += 1
		return (count, arr)
	else:
		if arr[1] > 0 and arr[2] > 0:
			arr[1] -= 1
			arr[2] -= 1
			count += 1
		if arr[0] > 0 and arr[2] > 0:
			arr[0] -= 1
			arr[2] -= 1
			count += 1
		if arr[0] > 0 and arr[1] > 0:
			arr[0] -= 1
			arr[1] -= 1
			count += 1
		return (count, arr)

def three(arr, count):
	if arr[0] > 0 and arr[1] > 0 and (arr[2] > 0):
		arr[0] -= 1
		arr[1] -= 1
		arr[2] -= 1
		count += 1
	return (count, arr)
t = int(input())
for _ in range(t):
	d = list(map(int, input().split()))
	count = 0
	(count, d) = one(d)
	if count == 0 or (min(d) == max(d) and min(d) == 0):
		print(count)
	else:
		(count, d) = two(d, count)
		(count, d) = three(d, count)
		print(count)


from sys import stdin, stdout
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	cnt = 0
	if a > 0:
		cnt += 1
		a -= 1
	if b > 0:
		cnt += 1
		b -= 1
	if c > 0:
		cnt += 1
		c -= 1
	if c > b and c > a:
		(a, c) = (c, a)
	if c > b:
		(b, c) = (c, b)
	if a > 0 and b > 0:
		cnt += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		cnt += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		cnt += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
	print(cnt)


for _ in range(int(input())):
	L = [int(x) for x in input().strip().split(' ')]
	m = min(L)
	if m >= 4:
		print(7)
	else:
		ans = 0
		if L[0]:
			ans += 1
			L[0] -= 1
		if L[1]:
			ans += 1
			L[1] -= 1
		if L[2]:
			ans += 1
			L[2] -= 1
		(a, b, c) = sorted(L, reverse=True)
		if a and b:
			ans += 1
			a -= 1
			b -= 1
		if b and c:
			ans += 1
			b -= 1
			c -= 1
		if c and a:
			ans += 1
			c -= 1
			a -= 1
		if a and b and c:
			ans += 1
		print(ans)


import sys
from collections import Counter
from itertools import combinations

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check(A, comb):
	for a in comb:
		A[a] -= 1
	if min(A) < 0:
		return False
	else:
		return True
for _ in range(INT()):
	A = LIST()
	A.sort(reverse=True)
	cnt = 0
	for i in range(1, 4):
		for comb in combinations(range(3), i):
			tmp = A[:]
			if check(A, comb):
				cnt += 1
			else:
				A = tmp
	print(cnt)


t = int(input())
for i in range(t):
	(m, n, o) = map(int, input().split())
	a = max(m, n, o)
	c = min(m, n, o)
	b = m + n + o - a - c
	d = 0
	if a != 0:
		d += 1
		a -= 1
	if b != 0:
		d += 1
		b -= 1
	if c != 0:
		d += 1
		c -= 1
	if a != 0 and b != 0:
		d += 1
		a -= 1
		b -= 1
	if a != 0 and c != 0:
		d += 1
		a -= 1
		c -= 1
	if b != 0 and c != 0:
		d += 1
		b -= 1
		c -= 1
	if a != 0 and b != 0 and (c != 0):
		d += 1
	print(d)
	d = 0


n = int(input())
for i in range(n):
	(c, b, a) = sorted(map(int, input().split()))
	k = 0
	if a > 0:
		k += 1
		a -= 1
	if b > 0:
		k += 1
		b -= 1
	if c > 0:
		k += 1
		c -= 1
	if a > 0 and b > 0:
		k += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		k += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		k += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		k += 1
	print(k)


from math import inf
t = int(input())
for q in range(t):
	L = [int(i) for i in input().split()]
	L.sort()
	(a, b, c) = L
	sc = 0
	for i in range(1, 8):
		if a >= i // 4 and b >= i // 2 % 2 and (c >= i % 2):
			a -= i // 4
			b -= i // 2 % 2
			c -= i % 2
			sc += 1
	print(sc)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	if c == 0:
		print(0)
	elif b == 0:
		print(1)
	elif a == 0 and b == 1:
		print(2)
	elif a == 0 and b > 1:
		print(3)
	else:
		base = 3
		a -= 1
		b -= 1
		c -= 1
		if b == 0:
			print(base)
		elif a == 0 and b >= 1:
			print(base + 1)
		elif a == 1 and c == 1:
			print(base + 1)
		elif a == 1:
			print(base + 2)
		elif a == 2:
			print(base + 3)
		else:
			print(base + 4)


T = int(input())
for ti in range(T):
	count = 0
	__abc = list(map(int, input().split()))
	for i in range(3):
		if __abc[i] > 0:
			__abc[i] -= 1
			count += 1
	__abc.sort()
	if __abc[1] > 0 and __abc[2] > 0:
		__abc[1] -= 1
		__abc[2] -= 1
		count += 1
	if __abc[0] > 0 and __abc[2] > 0:
		__abc[0] -= 1
		__abc[2] -= 1
		count += 1
	if __abc[0] > 0 and __abc[1] > 0:
		__abc[0] -= 1
		__abc[1] -= 1
		count += 1
	if all(__abc):
		count += 1
	print(count)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = sorted([a, b, c])
	mat = [[0, 0, 1], [0, 1, 1], [0, 2, 2], [1, 2, 2], [2, 2, 3], [3, 3, 3], [4, 4, 4]]
	mat.append(l)
	mat = sorted(mat, reverse=True)
	ans = mat.index(l)
	print(7 - ans)


import sys
input = sys.stdin.readline
t = int(input())
from itertools import product
pt = [bits for bits in product([0, 1], repeat=3)]
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	for bits in product([0, 1], repeat=8):
		sum_b = [0, 0, 0]
		for (idx, bit) in enumerate(bits):
			if bit == 1:
				sum_b[0] += pt[idx][0]
				sum_b[1] += pt[idx][1]
				sum_b[2] += pt[idx][2]
		if sum_b[0] <= a and sum_b[1] <= b and (sum_b[2] <= c):
			ans = max(ans, sum(bits[1:]))
	print(ans)


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


n = int(input())
for i in range(n):
	p = 0
	(a, b, c) = map(int, input().split())
	if a > 3 and c > 3 and (b > 3):
		p += 1
	if a > 0:
		p += 1
		a -= 1
	if b > 0:
		p += 1
		b -= 1
	if c > 0:
		p += 1
		c -= 1
	if a > 0 and c > 0 and (b > 0):
		if a > 1 and c > 1 and (b > 1):
			p += 3
		elif a > 1 or c > 1 or b > 1:
			p += 2
		else:
			p += 1
	elif a + b + c != 0:
		if a + b + c - max(a, b, c) != 0:
			p += 1
	print(p)


for i in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	s = 0
	if l[0] >= 4 and l[1] >= 4 and (l[2] >= 4):
		print(7)
	else:
		if l[0] > 0:
			l[0] -= 1
			s += 1
		if l[1] > 0:
			l[1] -= 1
			s += 1
		if l[2] > 0:
			l[2] -= 1
			s += 1
		if l[0] > 0 and l[2] > 0:
			l[0] -= 1
			l[2] -= 1
			s += 1
		if l[2] > 0 and l[1] > 0:
			l[2] -= 1
			l[1] -= 1
			s += 1
		if l[1] > 0 and l[0] > 0:
			l[1] -= 1
			l[0] -= 1
			s += 1
		if l[0] > 0 and l[1] > 0 and (l[2] > 0):
			s += 1
		print(s)


test_number = int(input())
for i in range(test_number):
	dishes = sorted(list(map(int, input().split())), reverse=True)
	visitor = 0
	for i in range(len(dishes)):
		if dishes[i] > 0:
			dishes[i] -= 1
			visitor += 1
	if dishes[0] > 0 and dishes[1] > 0:
		dishes[0] -= 1
		dishes[1] -= 1
		visitor += 1
	if dishes[0] > 0 and dishes[2] > 0:
		dishes[0] -= 1
		dishes[2] -= 1
		visitor += 1
	if dishes[1] > 0 and dishes[2] > 0:
		dishes[1] -= 1
		dishes[2] -= 1
		visitor += 1
	if dishes[0] > 0 and dishes[1] > 0 and (dishes[2] > 0):
		visitor += 1
	print(visitor)


from sys import stdin
a = int(stdin.readline())
for k in range(0, a):
	b = stdin.readline().split()
	A = int(b[0])
	B = int(b[1])
	C = int(b[2])
	count = 0
	if A > 0:
		A -= 1
		count += 1
	if B > 0:
		B -= 1
		count += 1
	if C > 0:
		C -= 1
		count += 1
	J = [A, B, C]
	if J.count(1) == 3 and J.count(0) == 0:
		count += 1
		print(count)
		continue
	if (J.count(1) == 2 or J.count(1) == 1) and J.count(0) == 0:
		count += 2
		print(count)
		continue
	if A > 0 and B > 0:
		A -= 1
		B -= 1
		count += 1
	if A > 0 and C > 0:
		A -= 1
		C -= 1
		count += 1
	if B > 0 and C > 0:
		B -= 1
		C -= 1
		count += 1
	if (A > 0 and B > 0) and C > 0:
		count += 1
	print(count)


import sys, math, cmath, time
start_time = time.time()

def solve():
	(a, b, c) = sorted(invr())
	if c == 0:
		q = 0
	elif c >= 1 and b == 0:
		q = 1
	elif c >= 1 and b == 1 and (a == 0):
		q = 2
	elif c >= 1 and b == 1 and (a == 1) or (c > 1 and b > 1 and (a == 0)):
		q = 3
	elif c == 2 and b == 2 and (a == 2) or (c >= 2 and b >= 2 and (a == 1)):
		q = 4
	elif c > 2 and a == 2:
		q = 5
	elif c > 2 and a == 3:
		q = 6
	else:
		q = 7
	print(q)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


def main_function():
	substractors = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
	output_list = []
	for i in range(int(input())):
		vector = sorted([int(a) for a in input().split(' ')], reverse=True)
		counter = 0
		for i in substractors:
			if vector[0] >= i[0] and vector[1] >= i[1] and (vector[2] >= i[2]):
				counter += 1
				vector[0] -= i[0]
				vector[1] -= i[1]
				vector[2] -= i[2]
		output_list.append(str(counter))
	return '\n'.join(output_list)
print(main_function())


from itertools import product
a = [0, 1]
ptn = list(product(a, repeat=3))
ptn.sort(key=lambda x: sum(x))
n = int(input())
for _ in range(n):
	abc = list(map(int, input().split()))
	abc.sort()
	(a, b, c) = abc
	cnt = 0
	for (i, j, k) in ptn[1:]:
		if a - i >= 0 and b - j >= 0 and (c - k >= 0):
			a -= i
			b -= j
			c -= k
			cnt += 1
	print(cnt)


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


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort()
	(a, b, c) = l
	count = 0
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	if c > 0 and b > 0:
		count += 1
		c -= 1
		b -= 1
	x = max(b, c)
	y = min(b, c)
	if a > 0 and x > 0:
		count += 1
		a -= 1
		x -= 1
	if a > 0 and y > 0:
		count += 1
		a -= 1
		y -= 1
	if a > 0 and y > 0 and (x > 0):
		count += 1
	print(count)


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	(a, b, c) = map(int, sys.stdin.readline().strip().split())
	visitors = 0
	if a > 0:
		visitors += 1
		a -= 1
	if b > 0:
		visitors += 1
		b -= 1
	if c > 0:
		visitors += 1
		c -= 1
	if a == max(a, b, c):
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			visitors += 1
			c -= 1
			b -= 1
	elif b == max(a, b, c):
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
		if c > 0 and b > 0:
			visitors += 1
			c -= 1
			b -= 1
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
	else:
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
		if c > 0 and b > 0:
			visitors += 1
			c -= 1
			b -= 1
	if a > 0 and b > 0 and (c > 0):
		visitors += 1
		a -= 1
		b -= 1
		c -= 1
	sys.stdout.write(str(visitors) + '\n')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	if a:
		a -= 1
		ans += 1
	if b:
		b -= 1
		ans += 1
	if c:
		c -= 1
		ans += 1
	if (a > 0) + (b > 0) + (c > 0) == 2:
		ans += 1
	if (a > 0) + (b > 0) + (c > 0) == 3:
		if min([a, b, c]) >= 3:
			ans += 4
		elif min([a, b, c]) >= 2:
			ans += 3
		elif max([a, b, c]) >= 2:
			ans += 2
		else:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		x = [a, b, c]
		x.sort()
		if x[0] == 3:
			print(6)
		elif x[0] == 2:
			if sum(x) >= 7:
				print(5)
			else:
				print(4)
		elif x[0] == 1:
			if x[1] >= 2:
				print(4)
			else:
				print(3)
		elif x[0] == 0:
			if x[1] >= 2:
				print(3)
			elif x[1] == 1:
				print(2)
			else:
				print(min(x[2], 1))


def solve(a, b, c):
	count = 0
	if a:
		count += 1
		a -= 1
	if b:
		count += 1
		b -= 1
	if c:
		count += 1
		c -= 1
	if a and b:
		count += 1
		a -= 1
		b -= 1
	if b and c:
		count += 1
		b -= 1
		c -= 1
	if c and a:
		count += 1
		c -= 1
		a -= 1
	if a and b and c:
		count += 1
	return count
t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	print(max(solve(a, b, c), solve(b, c, a), solve(c, b, a)))
	t -= 1


def solution():
	t = int(input())
	for _ in range(t):
		p = list(map(int, input().split(' ')))
		print(serve(p, [(0, 0, 0)]))

def serve(prepared, servedList):
	if sum(prepared) == 0:
		return 0
	nxt = nextServe(servedList[-1])
	if nxt == -1:
		return 0
	results = [0]
	while nxt != -1:
		if prepared[0] < nxt[0] or prepared[1] < nxt[1] or prepared[2] < nxt[2]:
			nxt = nextServe(nxt)
			continue
		processed = prepared.copy()
		processed[0] -= nxt[0]
		processed[1] -= nxt[1]
		processed[2] -= nxt[2]
		results.append(1 + serve(processed, servedList + [nxt]))
		nxt = nextServe(nxt)
	return max(results)

def nextServe(s):
	[dump, cran, panc] = s
	if (dump, cran, panc) == (0, 0, 0):
		return (0, 0, 1)
	elif (dump, cran, panc) == (0, 0, 1):
		return (0, 1, 0)
	elif (dump, cran, panc) == (0, 1, 0):
		return (1, 0, 0)
	elif (dump, cran, panc) == (1, 0, 0):
		return (1, 0, 1)
	elif (dump, cran, panc) == (1, 0, 1):
		return (1, 1, 0)
	elif (dump, cran, panc) == (1, 1, 0):
		return (0, 1, 1)
	elif (dump, cran, panc) == (0, 1, 1):
		return (1, 1, 1)
	else:
		return -1
solution()


a = int(input())
r = 0
c = list()
while r < a:
	b = [int(b) for b in input().split()]
	b.sort()
	if b[0] >= 4:
		c.append(7)
	elif b[0] == 3:
		c.append(6)
	elif b[0] == 2:
		if b[2] == 2:
			c.append(4)
		else:
			c.append(5)
	elif b[0] == 1:
		if b[1] < 2:
			c.append(3)
		else:
			c.append(4)
	elif b[2] == 0:
		c.append(0)
	elif b[1] == 0 and b[2] >= 1:
		c.append(1)
	elif b[1] == 1:
		c.append(2)
	else:
		c.append(3)
	r = r + 1
r = 0
while r < a:
	print(c[r])
	r = r + 1


testcase = int(input())
while testcase:
	(x, y, z) = list(map(int, input().split()))
	r = max(x, y, z)
	t = min(x, y, z)
	s = x + y + z - r - t
	(x, y, z) = (r, s, t)
	dp = [(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
	total = 0
	for (xx, yy, zz) in dp:
		if x >= xx and y >= yy and (z >= zz):
			total += 1
			x -= xx
			y -= yy
			z -= zz
	print(total)
	testcase -= 1


for _ in range(int(input())):
	A = list(map(int, input().split()))
	A.sort()
	ans = 0
	if A[0] >= 4:
		ans = 7
	else:
		if A[0] >= 1:
			A[0] -= 1
			ans += 1
		if A[1] >= 1:
			A[1] -= 1
			ans += 1
		if A[2] >= 1:
			A[2] -= 1
			ans += 1
		if A[2] >= 1 and A[1] >= 1:
			A[2] -= 1
			A[1] -= 1
			ans += 1
		if A[2] >= 1 and A[0] >= 1:
			A[0] -= 1
			A[2] -= 1
			ans += 1
		if A[1] >= 1 and A[0] >= 1:
			A[0] -= 1
			A[1] -= 1
			ans += 1
		if A[0] >= 1 and A[2] >= 1 and (A[1] >= 1):
			ans += 1
	print(ans)


t = int(input())
while t > 0:
	z = 0
	arr = list(map(int, input().split(' ')))
	arr.sort()
	if arr[0] > 0:
		z += 1
		arr[0] -= 1
	if arr[1] > 0:
		z += 1
		arr[1] -= 1
	if arr[2] > 0:
		z += 1
		arr[2] -= 1
	if arr[1] > 0 and arr[2] > 0:
		z += 1
		arr[1] -= 1
		arr[2] -= 1
	if arr[0] > 0 and arr[2] > 0:
		z += 1
		arr[0] -= 1
		arr[2] -= 1
	if arr[0] > 0 and arr[1] > 0:
		z += 1
		arr[0] -= 1
		arr[1] -= 1
	if arr[0] > 0 and arr[1] > 0 and (arr[2] > 0):
		z += 1
		arr[0] -= 1
		arr[1] -= 1
		arr[2] -= 1
	print(z)
	t -= 1


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

def lint():
	return list(map(int, input().split()))

def fint():
	return list(map(int, stdin.readline().split()))

def find(c, l):
	ans = 0
	for i in l:
		for j in range(3):
			if c[j] < i[j]:
				break
		else:
			C = list(c)
			L = list(l)
			L.remove(i)
			for j in range(3):
				C[j] -= i[j]
			ans = max(ans, 1 + find(C, L))
	return ans

def main():
	L = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
	C = lint()
	print(find(C, L))
t = int(input())
for i in range(t):
	main()


def do_solve(cnt, u):
	if u & 1:
		return False
	for i in range(1, 8):
		if not u & 1 << i:
			continue
		for j in range(3):
			if not i & 1 << j:
				continue
			if cnt[j]:
				cnt[j] -= 1
			else:
				return False
	return True

def solve(a, b, c):
	cnt = [a, b, c]
	res = 0
	for i in range(1, 1 << 8):
		b = '{:b}'.format(i).count('1')
		if b <= res:
			continue
		if do_solve(cnt[:], i):
			res = max(res, '{:b}'.format(i).count('1'))
	return res
assert do_solve([1, 2, 1], 7) == False
assert do_solve([1, 2, 1], 2) == True
assert do_solve([1, 2, 1], (1 << 8) - 1) == False
assert solve(1, 2, 1) == 3
assert solve(0, 0, 0) == 0
assert solve(9, 1, 7) == 4
assert solve(2, 2, 3) == 5
T = int(input())
for case_ in range(T):
	(a, b, c) = map(int, input().split())
	print(solve(a, b, c))


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)


t = int(input())
for _ in range(t):
	x = list(map(int, input().split()))
	x.sort()
	(a, b, c) = x
	if a >= 4:
		print(7)
	elif a >= 3:
		print(6)
	elif a >= 2 and c >= 3:
		print(5)
	elif a >= 1 and b >= 2:
		print(4)
	elif a >= 1:
		print(3)
	elif a >= 0 and b >= 2:
		print(3)
	elif a >= 0 and b >= 1:
		print(2)
	elif a >= 0 and c >= 1:
		print(1)
	else:
		print(0)


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		ans = 0
		(a, b, c) = map(int, input().split())
		if a > 0:
			ans += 1
			a -= 1
		if b > 0:
			ans += 1
			b -= 1
		if c > 0:
			ans += 1
			c -= 1
		(a, b, c) = sorted([a, b, c])
		if a >= 3:
			ans += 4
		elif a == 2:
			ans += 3
		elif a == 1:
			if c == 1:
				ans += 1
			else:
				ans += 2
		elif a == 0:
			if b > 0 and c > 0:
				ans += 1
		print(ans)
main()


import math
q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	if l[0] > 0:
		ans += 1
		l[0] -= 1
	if l[1] > 0:
		ans += 1
		l[1] -= 1
	if l[2] > 0:
		ans += 1
		l[2] -= 1
	if l[2] > 0 and l[1] > 0:
		ans += 1
		l[2] -= 1
		l[1] -= 1
	if l[2] > 0 and l[0] > 0:
		ans += 1
		l[2] -= 1
		l[0] -= 1
	if l[1] > 0 and l[0] > 0:
		ans += 1
		l[0] -= 1
		l[1] -= 1
	if l[0] > 0 and l[1] > 0 and (l[2] > 0):
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	visitors = 0
	dishes = [a, b, c]
	dishes.sort()
	(a, b, c) = (dishes[0], dishes[1], dishes[2])
	if a >= 1:
		a -= 1
		visitors += 1
	if b >= 1:
		b -= 1
		visitors += 1
	if c >= 1:
		c -= 1
		visitors += 1
	if b >= 1 and c >= 1:
		c -= 1
		b -= 1
		visitors += 1
	if a >= 1 and c >= 1:
		a -= 1
		c -= 1
		visitors += 1
	if a >= 1 and b >= 1:
		a -= 1
		b -= 1
		visitors += 1
	if a >= 1 and b >= 1 and (c >= 1):
		a -= 1
		b -= 1
		c -= 1
		visitors += 1
	print(visitors)


t = int(input())
ls = [[[1, 1, 0], [1, 0, 1], [0, 1, 1]], [[1, 0, 1], [1, 1, 0], [0, 1, 1]], [[1, 0, 1], [0, 1, 1], [1, 1, 0]], [[1, 1, 0], [0, 1, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0], [1, 0, 1]], [[0, 1, 1], [1, 0, 1], [1, 1, 0]]]
for _ in range(t):
	(a, b, c) = map(int, input().split())
	count = 0
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	ma_count = 0
	can_a = 0
	can_b = 0
	can_c = 0
	for m in range(6):
		tem_a = a
		tem_b = b
		tem_c = c
		tem_count = 0
		for (i, j, k) in ls[m]:
			if tem_a - i >= 0 and tem_b - j >= 0 and (tem_c - k >= 0):
				tem_count += 1
				tem_a -= i
				tem_b -= j
				tem_c -= k
		if tem_count > ma_count:
			ma_count = tem_count
			can_a = tem_a
			can_b = tem_b
			can_c = tem_c
	a = can_a
	b = can_b
	c = can_c
	count += ma_count
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)


t = int(input())
while t != 0:
	list1 = list(map(int, input().split()))
	count = 0
	if list1[0] > 0:
		count += 1
		list1[0] -= 1
	if list1[1] > 0:
		count += 1
		list1[1] -= 1
	if list1[2] > 0:
		count += 1
		list1[2] -= 1
	list1.sort()
	if list1[-1] > 0 and list1[0] > 0:
		count += 1
		list1[-1] -= 1
		list1[0] -= 1
	if list1[-1] > 0 and list1[1] > 0:
		count += 1
		list1[-1] -= 1
		list1[1] -= 1
	if list1[1] > 0 and list1[0] > 0:
		count += 1
		list1[1] -= 1
		list1[0] -= 1
	if list1[-1] > 0 and list1[1] > 0 and (list1[0] > 0):
		count += 1
		list1[-1] -= 1
		list1[0] -= 1
		list1[1] -= 1
	print(count)
	t -= 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	s = [a, b, c]
	zero = 0
	one = 0
	two = 0
	th3 = 0
	the = 0
	for i in s:
		if i == 0:
			zero += 1
		elif i == 1:
			one += 1
		elif i == 2:
			two += 1
		elif i == 3:
			th3 += 1
		else:
			the += 1
	if zero == 3:
		print(0)
		continue
	elif zero == 2:
		print(1)
		continue
	elif zero == 1:
		if one >= 1:
			print(2)
			continue
		else:
			print(3)
			continue
	if one == 1:
		print(4)
		continue
	elif one == 2 or one == 3:
		print(3)
		continue
	if two == 1 or two == 2:
		print(5)
		continue
	elif two == 3:
		print(4)
		continue
	if th3 == 3 or th3 == 2 or th3 == 1:
		print(6)
		continue
	else:
		print(7)


for i in range(int(input())):
	p = 0
	(a, b, c) = map(int, input().split())
	x = min(a, b, c)
	y = sorted([a, b, c])
	(a, b, c) = (y[2], y[1], y[0])
	p += 3 - [a, b, c].count(0)
	(a, b, c) = (max(0, a - 1), max(0, b - 1), max(0, c - 1))
	x = min(a, b)
	p += min(1, x)
	(a, b) = (a - min(1, x), b - min(1, x))
	x = min(b, c)
	p += min(1, x)
	(b, c) = (b - min(1, x), c - min(1, x))
	x = min(a, c)
	p += min(1, x)
	(a, c) = (a - min(1, x), c - min(1, x))
	x = min(a, b, c)
	p += min(1, x)
	print(p)


from itertools import permutations

def read_int():
	return int(input())

def read_ints():
	return [int(x) for x in input().split()]
d = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
t = read_int()
for i in range(t):
	x = read_ints()
	x = list(reversed(sorted(x)))
	r = 0
	for s in d:
		if s[0] <= x[0] and s[1] <= x[1] and (s[2] <= x[2]):
			r += 1
			x[0] -= s[0]
			x[1] -= s[1]
			x[2] -= s[2]
	print(r)


import itertools
arr = list(itertools.permutations(['a', 'b', 'c', 'ab', 'bc', 'ca', 'abc']))

def solve():
	(a, b, c) = map(int, input().split(' '))
	if a >= 4 and b >= 4 and (c >= 4):
		return 7
	ans = 0
	for x in arr:
		tmp = 0
		(xa, xb, xc) = (a, b, c)
		for i in x:
			ca = i.count('a')
			cb = i.count('b')
			cc = i.count('c')
			if ca <= xa and cb <= xb and (cc <= xc):
				(xa, xb, xc) = (xa - ca, xb - cb, xc - cc)
				tmp += 1
		ans = max(ans, tmp)
	return ans
t = int(input())
for _ in range(t):
	print(solve())


n = int(input())
for collection in range(n):
	final = 0
	dishes = [int(i) for i in input().split()]
	for i in range(3):
		if dishes[i] > 0:
			dishes[i] -= 1
			final += 1
	used = []
	toBeUsed = [[0, 1], [0, 2], [1, 2]]
	if dishes[0] > 0:
		for i in range(1, 3):
			if dishes[i] == max(dishes[1], dishes[2]) and dishes[i] != 0:
				used.append([0, i])
				toBeUsed.remove([0, i])
				dishes[0] -= 1
				dishes[i] -= 1
				final += 1
				break
	for (index1, index2) in toBeUsed:
		if dishes[index1] * dishes[index2] > 0:
			dishes[index1] -= 1
			dishes[index2] -= 1
			final += 1
	if dishes[0] * dishes[1] * dishes[2] > 0:
		final += 1
	print(final)


def solve():
	(a, b, c) = map(int, input().split())
	ans = 0
	if a < b:
		(a, b) = (b, a)
	if a < c:
		(a, c) = (c, a)
	if b < c:
		(b, c) = (c, b)
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		ans += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		ans += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	x = 0
	for n in range(1, 8):
		(da, db, dc) = map(int, bin(n)[2:].zfill(3))
		if a >= da and b >= db and (c >= dc):
			(a, b, c) = (a - da, b - db, c - dc)
			x += 1
	print(x)


local = False
if local:
	file = open('A.txt', 'r')

def readInput():
	if local:
		return file.readline()
	else:
		return input()

def solve(a, b, c):
	ans = 0
	(c, b, a) = sorted([a, b, c])
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	if a > 0 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	return ans
t = int(readInput())
for i in range(t):
	abc = readInput().split()
	(a, b, c) = (int(abc[0]), int(abc[1]), int(abc[2]))
	print(solve(a, b, c))


tt = int(input())
for x in range(tt):
	dcp = input().split(' ')
	r = int(dcp[0])
	s = int(dcp[1])
	t = int(dcp[2])
	d = max(r, s, t)
	p = min(r, s, t)
	c = r + s + t - (d + p)
	n = 0
	if d > 0:
		n += 1
		d -= 1
	if c > 0:
		n += 1
		c -= 1
	if p > 0:
		n += 1
		p -= 1
	if d > 0 and c > 0:
		n += 1
		d -= 1
		c -= 1
	if d > c:
		if d > 0 and p > 0:
			n += 1
			d -= 1
			p -= 1
		if c > 0 and p > 0:
			n += 1
			c -= 1
			p -= 1
	else:
		if d > 0 and p > 0:
			n += 1
			d -= 1
			p -= 1
		if c > 0 and p > 0:
			n += 1
			c -= 1
			p -= 1
	if d > 0 and c > 0 and (p > 0):
		d -= 1
		c -= 1
		p -= 1
		n += 1
	print(n)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l = sorted(l)
	al = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	count = 0
	for i in al:
		flag = 0
		for j in range(len(i)):
			if l[j] < i[j]:
				flag = 1
		if flag == 0:
			count += 1
			for j in range(len(i)):
				l[j] -= i[j]
	print(count)


def solve():
	l = [int(x) for x in input().split()]
	l.sort()
	ppl = 0
	for i in range(3):
		if l[i] != 0:
			l[i] -= 1
			ppl += 1
	for j in range(3):
		if l[j] != 0 and l[j - 1] != 0:
			l[j] -= 1
			l[j - 1] -= 1
			ppl += 1
	if l[0] != 0 and l[1] != 0 and (l[2] != 0):
		ppl += 1
	print(ppl)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	x = 0
	for i in range(3):
		if a[i] > 0:
			x += 1
	if a[0] > 1 and a[1] > 1:
		x += 1
	if a[2] > 1 and a[1] > 1:
		x += 1
	if a[0] > 1 and a[2] > 1:
		x += 1
	if a == [2, 2, 2]:
		x -= 2
	elif 2 in a and x == 6:
		x -= 1
	if min(a) > 3:
		x += 1
	print(x)


tests = int(input())
lista = [1, 2, 4, 3, 5, 6, 7]
for te in range(tests):
	answer = 0
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	for i in range(len(lista)):
		bit = lista[i]
		flag = 0
		for j in range(3):
			if 1 & bit >> j:
				if arr[j] <= 0:
					flag = 1
		if flag == 0:
			for j in range(3):
				if 1 & bit >> j:
					arr[j] -= 1
			answer += 1
	print(answer)


t = int(input())
while t > 0:
	t = t - 1
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	a = x[0]
	b = x[1]
	c = x[2]
	k = 0
	if a > 0:
		k += 1
		a = a - 1
	if b > 0:
		k += 1
		b = b - 1
	if c > 0:
		k += 1
		c = c - 1
	if a > 0 and b > 0:
		k += 1
		a = a - 1
		b = b - 1
	if c > 0 and b > 0:
		k += 1
		c = c - 1
		b = b - 1
	if a > 0 and c > 0:
		k += 1
		a = a - 1
		c = c - 1
	if a > 0 and b > 0 and (c > 0):
		k += 1
		a = a - 1
		b = b - 1
		c = c - 1
	print(k)


try:

	def maxCustomers(dishes):
		dishes = sorted(dishes, reverse=True)
		maximum = 0
		for i in range(0, 3):
			if dishes[i] > 0:
				maximum = maximum + 1
				dishes[i] = dishes[i] - 1
		for i in range(0, 2):
			if dishes[i] > 0 and dishes[i + 1] > 0:
				maximum = maximum + 1
				dishes[i] = dishes[i] - 1
				dishes[i + 1] = dishes[i + 1] - 1
		if dishes[0] > 0 and dishes[2] > 0:
			dishes[0] = dishes[0] - 1
			dishes[2] = dishes[2] - 1
			maximum = maximum + 1
		if dishes[0] > 0 and dishes[1] > 0 and (dishes[2] > 0):
			maximum = maximum + 1
		print(maximum)

	def main():
		testCases = int(input())
		for i in range(testCases):
			dishes = list(map(int, input().split()))
			maxCustomers(dishes)
	if __name__ == '__main__':
		main()
except Exception:
	pass


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


t = int(input())
for q in range(0, t):
	(a, b, c) = map(int, input().split())
	ans = 3
	if a == 0:
		ans -= 1
	else:
		a -= 1
	if b == 0:
		ans -= 1
	else:
		b -= 1
	if c == 0:
		ans -= 1
	else:
		c -= 1
	arr = [a, b, c]
	arr.sort()
	a = arr[0]
	b = arr[1]
	c = arr[2]
	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 b != 0 and a != 0:
		ans += 1
		b -= 1
		a -= 1
	ans += 1
	if a == 0 or b == 0 or c == 0:
		ans -= 1
	print(ans)


for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	ans = 0
	m = min(a)
	if m >= 4:
		print(7)
	elif m == 3:
		print(6)
	elif m == 2:
		if a.count(2) == 1:
			print(5)
		elif a.count(2) == 2:
			print(5)
		else:
			print(4)
	elif m == 1:
		if a.count(1) == 1:
			print(4)
		elif a.count(1) >= 2:
			print(3)
	elif m == 0:
		if a.count(0) == 1:
			if a.count(1) >= 1:
				print(2)
			else:
				print(3)
		elif a.count(0) == 2:
			print(1)
		else:
			print(0)


for tin in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a >= 1 and b >= 1 and (c >= 1):
		x = 0
		x += 3
		a -= 1
		b -= 1
		c -= 1
		if [a, b, c].count(1) == 3:
			x += 1
		elif [a, b, c].count(1) == 2:
			if [a, b, c].count(0) == 0:
				x += 2
			else:
				x += 1
		elif [a, b, c].count(1) == 1:
			if [a, b, c].count(0) == 1:
				x += 1
			elif [a, b, c].count(0) == 2:
				x += 0
			else:
				x += 2
		elif [a, b, c].count(1) == 0:
			if [a, b, c].count(0) == 1:
				x += 1
			elif [a, b, c].count(0) == 0:
				if a >= 3 and b >= 3 and (c >= 3):
					x += 4
				else:
					x += 3
		print(x)
	else:
		x = 0
		if [a, b, c].count(0) == 3:
			print(0)
		elif [a, b, c].count(0) == 2:
			print(1)
		else:
			x = 2
			a -= 1
			b -= 1
			c -= 1
			if a >= 1 and b >= 1 or (a >= 1 and c >= 1) or (b >= 1 and c >= 1):
				x += 1
			print(x)


import itertools
import copy
t = int(input())
abc_n = [[int(i) for i in input().split()] for j in range(t)]
l = [(0, 1), (0, 2), (1, 2)]
ans = 0
for i in range(t):
	abc_new = abc_n[i]
	tmp = 0
	for j in range(3):
		if abc_new[j] > 0:
			tmp += 1
			abc_new[j] -= 1
	tmp_old = tmp
	ans = 0
	for l in itertools.permutations(l, 3):
		abc = copy.deepcopy(abc_new)
		tmp = tmp_old
		for k in range(3):
			if abc[l[k][0]] > 0 and abc[l[k][1]] > 0:
				tmp += 1
				abc[l[k][0]] -= 1
				abc[l[k][1]] -= 1
		if abc[0] * abc[1] * abc[2] > 0:
			tmp += 1
		ans = max(ans, tmp)
	print(ans)


def solve():
	(a, b, c) = map(int, input().split())
	res = 0
	if a > 0:
		a -= 1
		res += 1
	if b > 0:
		b -= 1
		res += 1
	if c > 0:
		c -= 1
		res += 1
	arr = [a, b, c]
	arr.sort()
	a = arr[2]
	b = arr[1]
	c = arr[0]
	if a > 0 and b > 0:
		res += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		res += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		res += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		res += 1
	print(res)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	count = 0
	for n in range(1, 8):
		(x, y, z) = map(int, bin(n)[2:].zfill(3))
		if a >= x and b >= y and (c >= z):
			(a, b, c) = (a - x, b - y, c - z)
			count += 1
	print(count)


import sys

def fast_input():
	return sys.stdin.readline().strip()

def data_input():
	return [int(x) for x in fast_input().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(a, b, c) = data_input()
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		count += 1
		c -= 1
	data = sorted([a, b, c])
	(a, b, c) = data
	if a > 1 and b > 1 and (c > 1):
		count += 3
		a -= 2
		b -= 2
		c -= 2
	elif a > 0 and b > 0 and (c > 1):
		a -= 1
		b -= 1
		c -= 2
		count += 2
	elif b > 0 and c > 0:
		count += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)
	return
for ______ in range(int(fast_input())):
	solve_of_problem()


from itertools import permutations
pre = [[1], [2], [0], [1, 2], [1, 0], [2, 0], [1, 2, 0]]

def kk(L, d):
	c = 0
	for i in range(0, len(L)):
		h = pre[L[i]]
		temp = 0
		for j in h:
			if d[j] > 0:
				d[j] -= 1
			else:
				temp = 1
				break
		if temp == 0:
			c += 1
		else:
			break
	return c
s = [0, 1, 2, 3, 4, 5, 6]
L = list(permutations(s))
T = int(input())
for _ in range(0, T):
	(a, b, c) = map(int, input().split())
	ans = 0
	for i in L:
		ans = max(ans, kk(list(i), [a, b, c]))
	print(ans)


l = []
for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	for i in range(3):
		if a[i] > 0:
			a[i] -= 1
			c += 1
	if a[1] > 0 and a[2] > 0:
		a[1] -= 1
		a[2] -= 1
		c += 1
	if a[0] > 0 and a[1] > 0:
		a[0] -= 1
		a[1] -= 1
		c += 1
	if a[0] > 0 and a[2] > 0:
		a[0] -= 1
		a[2] -= 1
		c += 1
	if a[1] > 0 and a[2] > 0 and (a[0] > 0):
		c += 1
	l.append(c)
for i in l:
	print(i)


def I():
	return list(map(int, input().split()))
from itertools import chain, combinations

def powerset(iterable):
	s = list(iterable)
	return list(chain.from_iterable((combinations(s, r) for r in range(len(s) + 1))))
maxS = 1 * 3 + 2 * 3 + 3
allPosible = ['100', '010', '001', '110', '011', '101', '111']
s = powerset(allPosible)
sums = []
for i in s:
	(a, b, c) = (0, 0, 0)
	for j in i:
		if j[0] == '1':
			a += 1
		if j[1] == '1':
			b += 1
		if j[2] == '1':
			c += 1
	sums.append([a, b, c])
for __ in range(int(input())):
	(a, b, c) = I()
	m = 0
	for i in range(len(sums)):
		if a >= sums[i][0] and b >= sums[i][1] and (c >= sums[i][2]):
			m = max(len(s[i]), m)
	print(m)


arrs = []
for item in range(int(input())):
	arrs.append(list(map(int, input().split(' '))))
arrCount = [0 for _ in arrs]
for (i, arr) in enumerate(arrs):
	for numI in range(3):
		if arr[numI] != 0:
			arr[numI] -= 1
			arrCount[i] += 1
	r = range(3) if arr[0] > arr[1] else range(-1, 2)
	for numI in r:
		if arr[numI] != 0 and arr[numI - 1] != 0:
			arr[numI] -= 1
			arr[numI - 1] -= 1
			arrCount[i] += 1
	if arr[0] != 0 and arr[1] != 0 and (arr[2] != 0):
		arrCount[i] += 1
for count in arrCount:
	print(count)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations, combinations

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = 10 ** 9
mod = int(1000000000.0) + 7
for t in range(int(data())):
	a = mdata()
	ans = 0
	a.sort()
	if a[0] >= 4:
		out(7)
	elif a[0] == 3:
		out(6)
	elif a[0] == 2:
		if a[-1] == 2:
			out(4)
		else:
			out(5)
	elif a[0] == 1:
		if a[1] == 1:
			out(3)
		else:
			out(4)
	elif a[1] == 0:
		if a[-1] == 0:
			out(0)
		else:
			out(1)
	elif a[1] == 1:
		out(2)
	else:
		out(3)


c = {}
for x in range(1, 1 << 8):
	t = [0, 0, 0]
	v = 0
	for y in range(1, 8):
		if x >> y & 1:
			v += 1
			for i in range(3):
				if y >> i & 1:
					t[i] += 1
	if v:
		c[tuple(t)] = max(c.get(tuple(t), 0), v)
for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = 0
	for (k, v) in c.items():
		if a[0] >= k[0] and a[1] >= k[1] and (a[2] >= k[2]):
			b = max(b, v)
	print(b)


t = int(input())
while t:
	t -= 1
	a = sorted(list(map(int, input().split())))
	ans = 0
	for i in range(1, 8):
		b = list(map(int, list(bin(i)[2:].rjust(3, '0'))))
		for j in range(3):
			if a[j] < b[j]:
				break
		else:
			ans += 1
			for j in range(3):
				a[j] -= b[j]
	print(ans)


for x in range(int(input())):
	(d, l) = (0, list(map(int, input().split())))
	for i in range(3):
		if l[i] > 0:
			d += 1
			l[i] -= 1
	m = max(l)
	l.remove(m)
	if l[0] > 0 and m > 0:
		d += 1
		l[0] -= 1
		m -= 1
	if l[1] > 0 and m > 0:
		d += 1
		l[1] -= 1
		m -= 1
	if l[0] > 0 and l[1] > 0:
		d += 1
		l[0] -= 1
		l[1] -= 1
	if l.count(0) == 0 and m > 0:
		d += 1
	print(d)


for _ in range(int(input())):
	X = sorted(list(map(int, input().split())), reverse=True)
	N = 3 - X.count(0)
	for i in range(3):
		X[i] = max(0, X[i] - 1)
	for i in range(3):
		for j in range(i + 1, 3):
			if 0 not in [X[i], X[j]]:
				(X[i], X[j]) = (X[i] - 1, X[j] - 1)
				N += 1
	print(N + 1 if 0 not in X else N)


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


from itertools import combinations

def answer(elements):
	for i in range(len(elements)):
		perms = []
		count = 0
		dic = {'a': elements[i][0], 'b': elements[i][1], 'c': elements[i][2]}
		arr = [i[0] for i in sorted(dic.items(), key=lambda x: x[1], reverse=True)]
		for i in range(1, 4):
			perms += list(map(''.join, combinations(arr, i)))
		for p in perms:
			testResult = True
			for s in p:
				if dic.get(s) == 0:
					testResult = False
					break
			if testResult:
				count += 1
				for s in p:
					dic[s] -= 1
		print(count)
testCaseCount = int(input())
elements = []
for _ in range(testCaseCount):
	elements.append(list(map(int, input().split())))
answer(elements)


pat = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		k = 0
		for i in pat:
			if i[0] <= a and i[1] <= b and (i[2] <= c):
				a -= i[0]
				b -= i[1]
				c -= i[2]
				k += 1
		print(k)


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		ans = 0
		l = [a, b, c]
		l.sort(reverse=True)
		if l[0] > 0:
			l[0] -= 1
			ans += 1
		if l[1] > 0:
			l[1] -= 1
			ans += 1
		if l[2] > 0:
			l[2] -= 1
			ans += 1
		if l[0] > 0 and l[1] > 0:
			l[0] -= 1
			l[1] -= 1
			ans += 1
		if l[0] > 0 and l[2] > 0:
			l[0] -= 1
			l[2] -= 1
			ans += 1
		if l[1] > 0 and l[2] > 0:
			ans += 1
		print(ans)


import itertools
import copy
n = int(input())
for i in range(n):
	alpha = ['01', '12', '20']
	abc = list(map(int, input().split()))
	s = 0
	for j in range(3):
		if abc[j] > 0:
			abc[j] -= 1
			s += 1
	s2 = -1
	abc3 = []
	for k in itertools.permutations(alpha, 3):
		abc2 = copy.deepcopy(abc)
		s1 = 0
		for p in range(3):
			if abc2[int(k[p][0])] > 0 and abc2[int(k[p][1])] > 0:
				abc2[int(k[p][0])] -= 1
				abc2[int(k[p][1])] -= 1
				s1 += 1
		if s2 < s1:
			s2 = s1
			abc3 = abc2
	s += s2
	if abc3[0] > 0 and abc3[1] > 0 and (abc3[2] > 0):
		s += 1
	print(s)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	(a, b, c) = (l[0], l[1], l[2])
	count = 0
	if a > 0:
		count += 3
		a -= 1
		b -= 1
		c -= 1
	elif a == 0 and b > 0:
		count += 2
		b -= 1
		c -= 1
	elif a == 0 and b == 0 and (c > 0):
		count += 1
		c -= 1
	if a > 0 and c > 0:
		count += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		count += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0:
		count += 1
		a -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	(a, b, c) = a
	ans = 0
	if a:
		a -= 1
		ans += 1
	if b:
		b -= 1
		ans += 1
	if c:
		c -= 1
		ans += 1
	if a and b:
		a -= 1
		b -= 1
		ans += 1
	if a and c:
		a -= 1
		c -= 1
		ans += 1
	if b and c:
		b -= 1
		c -= 1
		ans += 1
	if a and b and c:
		ans += 1
	print(ans)


t = int(input())
for k in range(t):
	(a, b, c) = 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)


def useCombo(u):
	global cl
	global il
	for i in range(3):
		il[i] = il[i] - u[i]
	global c
	c += 1
	cl.remove(u)
cl = il = []
c = 0
t = int(input())
while t > 0:
	cl = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 1)]
	c = 0
	il = [int(i) for i in input().split()]
	il.sort(reverse=True)
	while len(cl) > 0:
		if 0 in il:
			k = il.index(0)
			tl = []
			for i in cl:
				if i[k] == 0:
					tl.append(i)
			cl = tl
			il[k] = -1
			continue
		useCombo(cl[0])
	print(c)
	t -= 1


for i in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	ans = 0
	if a > 0:
		a = min(3, a - 1)
		ans += 1
	if b > 0:
		b = min(3, b - 1)
		ans += 1
	if c > 0:
		c = min(3, c - 1)
		ans += 1
	x = abs(3 - a)
	if x == 3:
		if b >= 1 and c >= 1:
			print(ans + 1)
		else:
			print(ans)
	elif x == 2:
		if a == b == c:
			print(ans + 1)
		else:
			print(ans + 2)
	elif x == 1:
		print(6)
	elif x == 0:
		print(7)


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


def restaurant(n):
	n = n.split()
	n1 = int(n[0])
	n2 = int(n[1])
	n3 = int(n[2])
	t = min(n1, n2, n3)
	if t >= 4:
		return 7
	if t == 3:
		return 6
	if t == 2:
		count = 0
		for i in range(len(n)):
			if int(n[i]) == 2:
				count += 1
		if count == 3:
			return 4
		else:
			return 5
	if t == 1:
		count = 0
		for i in range(len(n)):
			if int(n[i]) == 1:
				count += 1
		if count == 1:
			return 4
		else:
			return 3
	if t == 0:
		count = 0
		for i in range(len(n)):
			if int(n[i]) == 0:
				count += 1
		if count == 2:
			return 1
		if count == 3:
			return 0
		else:
			count = 0
			for i in range(len(n)):
				if int(n[i]) >= 2:
					count += 1
			if count == 2:
				return 3
			else:
				return 2
t = int(input().strip())
for i in range(t):
	print(restaurant(input().strip()))


def mainn():
	for gg in range(int(input())):
		(a, b, c) = map(int, input().split())
		(a, b, c) = (max(a, max(b, c)), a + b + c - max(a, max(b, c)) - min(a, min(b, c)), min(a, min(b, c)))
		was = set([])
		f = 1
		ans = 0
		if a:
			ans += 1
			a -= 1
			f = 1
		if b:
			ans += 1
			b -= 1
			f = 1
		if c:
			ans += 1
			c -= 1
			f = 1
		if a and b:
			ans += 1
			a -= 1
			b -= 1
			f = 1
		if a and c:
			ans += 1
			a -= 1
			c -= 1
			f = 1
		if c and b:
			ans += 1
			c -= 1
			b -= 1
			f = 1
		if a and c and b:
			ans += 1
			a -= 1
			b -= 1
			c -= 1
			f = 1
		print(ans)
mainn()


for _ in [0] * int(input()):
	(a, b, c) = map(int, input().split())
	print((a > 0) + (b > 0) + (c > 0) + (a > 1 and b > 1 or (b > 1 and c > 1) or (c > 1 and a > 1)) + (a > 2 and b > 1 and (c > 1) or (a > 1 and b > 2 and (c > 1)) or (a > 1 and b > 1 and (c > 2))) + (a > 2 and b > 2 and (c > 2)) + (a > 3 and b > 3 and (c > 3)))


T = int(input())
for t in range(T):
	a = [int(x) for x in input().split()]
	a = sorted(a, reverse=True)
	ans = 0
	for i in range(3):
		if a[i] > 0:
			ans += 1
			a[i] -= 1
	if a[0] > 0 and a[2] > 0:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0:
		ans += 1
		a[0] -= 1
		a[1] -= 1
	if a[1] > 0 and a[2] > 0:
		ans += 1
		a[1] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		ans += 1
	print(ans)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(a, b, c) = inputnums()
	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 < b:
		(a, b) = (b, a)
	if a < c:
		(a, c) = (c, a)
	if b < c:
		(b, c) = (c, b)
	if a > 0 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if c > 0 and b > 0:
		ans += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	(a, b, c) = read_int_line()
	ans = 0
	l = [a, b, c]
	l.sort(reverse=True)
	(a, b, c) = l
	if c >= 4:
		print(7)
	elif c > 0:
		if c == 1:
			ans = 3
			a -= 1
			b -= 1
			c -= 1
			if b >= 1:
				ans += 1
			print(ans)
		elif c == 2:
			ans = 3
			a -= 1
			b -= 1
			c -= 1
			if a > 1:
				ans += 2
			else:
				ans += 1
			print(ans)
		elif c == 3:
			ans = 6
			print(ans)
		else:
			l = [a, b, c]
			l.sort(reverse=True)
			(a, b, c) = l
			if b == 0:
				ans = 1
			elif b == 1:
				ans = 2
			else:
				ans = 3
			print(ans)
	elif b > 1:
		print(3)
	elif b == 1:
		print(2)
	elif a > 0:
		print(1)
	else:
		print(0)


t = int(input())
for _ in range(t):
	s = input().split()
	ar = [int(s[0]), int(s[1]), int(s[2])]
	ans = 0
	ar.sort()
	if ar[2] - 1 >= 0:
		ans = 1
		if ar[1] - 1 >= 0:
			ans = 2
			if ar[2] - 2 >= 0 and ar[1] - 2 >= 0 or ar.count(0) == 0:
				ans = 3
				if ar[2] - 2 >= 0 and ar[1] - 2 >= 0 and (ar[0] - 1 >= 0):
					ans = 4
					if ar[2] - 3 >= 0 and ar[1] - 2 >= 0 and (ar[0] - 2 >= 0):
						ans = 5
						if ar[2] - 3 >= 0 and ar[1] - 3 >= 0 and (ar[0] - 3 >= 0):
							ans = 6
							if ar[2] - 4 >= 0 and ar[1] - 4 >= 0 and (ar[0] - 4 >= 0):
								ans = 7
	print(ans)


from math import gcd, sqrt, ceil

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
t = ii()
while t:
	t -= 1
	(a, b, c) = mi()
	s = 0
	if a > 0:
		s += 1
		a -= 1
	if b > 0:
		s += 1
		b -= 1
	if c > 0:
		s += 1
		c -= 1
	if c > b:
		(c, b) = (b, c)
	if b > a:
		(a, b) = (b, a)
	if a > 0 and b > 0:
		s += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		s += 1
		c -= 1
		a -= 1
	if b > 0 and c > 0:
		s += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		s += 1
	print(s)


t = int(input())
for i in range(t):
	(a, b, c) = sorted([int(i) for i in input().split()])
	if a >= 4:
		print(7)
	elif a >= 3:
		print(6)
	elif a >= 2 and c >= 3:
		print(5)
	elif a >= 1 and b >= 2:
		print(4)
	elif a >= 1 or b >= 2:
		print(3)
	elif a == 0 and b == 1:
		print(2)
	elif b == 0 and c > 0:
		print(1)
	elif c == 0:
		print(0)


from sys import stdin
from itertools import combinations
for _ in range(int(stdin.readline())):
	arr = [int(x) for x in stdin.readline().split()]
	arr.sort()
	(a, b, c) = (arr[0], arr[1], arr[2])
	ans = 0
	l = []
	for i in range(8):
		for i in [(0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)]:
			(na, nb, nc) = (i[0], i[1], i[2])
			if a >= na and b >= nb and (c >= nc):
				flag = True
				for it in l:
					if i[0] == it[0] and i[1] == it[1] and (i[2] == it[2]):
						flag = False
				if not flag:
					continue
				l.append(i)
				a -= na
				b -= nb
				c -= nc
				ans += 1
	print(ans)


for i in range(int(input())):
	count = 0
	zero_count = 0
	one_count = 0
	three = False
	serve = input().split()
	serve = [int(j) for j in serve]
	serve.sort()
	n_serve = serve.copy()
	for number in range(3):
		if serve[number] > 0:
			count += 1
			n_serve[number] -= 1
		if serve[0] == 3:
			three = True
		if n_serve[number] == 1:
			one = True
			one_count += 1
		if n_serve[number] == 0:
			zero = True
			zero_count += 1
	if three == True:
		count += 3
	if zero_count == 1:
		count += 1
	elif zero_count == 0 and 0 < one_count < 3:
		count += 2
	elif one_count == 3:
		count += 1
	elif zero_count == 0 and one_count == 0 and (three == False):
		count += 4
	else:
		pass
	print(count)


for _ in range(int(input())):
	lst = list(map(int, input().split()))
	lst.sort()
	if lst[2] == 0:
		print(0)
		continue
	if lst[0] >= 4:
		print(7)
	elif lst[0] == 3:
		print(6)
	elif lst[0] == 2:
		if lst[2] > 2:
			print(5)
		else:
			print(4)
	elif lst[0] == 1:
		if lst[1] - 1 > 0:
			print(4)
		else:
			print(3)
	elif lst[1] > 0:
		if lst[1] > 1:
			print(3)
		else:
			print(2)
	else:
		print(1)


import sys
from itertools import combinations

def solve(A, B, C):
	dishes = [A, B, C]
	possible = []
	for mask in range(1, 1 << 3):
		possible.append([int(c) for c in bin(mask)[2:].rjust(3, '0')])
	for count in reversed(range(len(possible) + 1)):
		for combo in combinations(possible, r=count):
			comboSum = [0, 0, 0]
			for vec in combo:
				for i in range(3):
					comboSum[i] += vec[i]
			if all((d >= c for (d, c) in zip(dishes, comboSum))):
				return count
	return 0
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(A, B, C) = map(int, input().split())
	ans = solve(A, B, C)
	print(ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque
import math

def main():
	for t in range(int(input())):
		a = list(map(int, input().split()))
		b = ['1', '10', '100', '11', '101', '110', '111']
		ma = 0
		for i in range(1, 128):
			z = bin(i)[2:]
			ans = 0
			x = a[:]
			for j in range(len(z)):
				if z[j] == '1':
					c = 0
					d = 0
					for k in range(len(b[j])):
						if b[j][-(k + 1)] == '1':
							c += 1
							if x[-(k + 1)] > 0:
								d += 1
					if c == d:
						ans += 1
						for k in range(len(b[j])):
							if b[j][-(k + 1)] == '1':
								x[-(k + 1)] -= 1
			ma = max(ma, ans)
		print(ma)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


T = int(input())
for i in range(T):
	co = 0
	w = list(map(int, input().split()))
	w.sort(reverse=True)
	a = w[0]
	b = w[1]
	c = w[2]
	if a > 0:
		a = a - 1
		co = co + 1
	if b > 0:
		b = b - 1
		co = co + 1
	if c > 0:
		c = c - 1
		co = co + 1
	if a > 0 and b > 0:
		a = a - 1
		b = b - 1
		co = co + 1
	if a > 0 and c > 0:
		a = a - 1
		c = c - 1
		co = co + 1
	if b > 0 and c > 0:
		b = b - 1
		c = c - 1
		co = co + 1
	if a > 0 and b > 0 and (c > 0):
		co = co + 1
	print(co)


a = [1, 2, 3, 12, 13, 23, 123]
t = int(input())
for i in range(t):
	c = list(map(int, input().split()))
	d = c
	ans = 0
	d.sort(reverse=True)
	for v in a:
		s = str(v)
		k = 0
		for j in s:
			x = int(j) - 1
			if d[x] > 0:
				k = k + 1
		if k == len(s):
			ans = ans + 1
			for h in s:
				x = int(h) - 1
				d[x] = d[x] - 1
	print(ans)


i = input
for _ in [0] * int(i()):
	(a, b, c) = sorted(map(int, i().split()))
	r = (a > 0) + (b > 0) + (c > 0) + (min(a, b, c) > 3)
	if c > 1 and b > 1:
		r += 1
		c -= 1
		b -= 1
	if c > 1 and a > 1:
		r += 1
		a -= 1
	if b > 1 and a > 1:
		r += 1
	print(r)


def solve(a, b, c):
	res = 0
	if a:
		res += 1
		a -= 1
	if b:
		res += 1
		b -= 1
	if c:
		res += 1
		c -= 1
	if c and a:
		res += 1
		c -= 1
		a -= 1
	if b and c:
		res += 1
		b -= 1
		c -= 1
	if a and b:
		res += 1
		a -= 1
		b -= 1
	if a and b and c:
		res += 1
		a -= 1
		b -= 1
		c -= 1
	return res
for t in range(int(input())):
	(a, b, c) = sorted([int(i) for i in input().split()])
	print(solve(a, b, c))


t = int(input())
for _ in range(t):
	a = sorted(list(map(int, input().split())))
	o = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	total = 0
	for (x, y, z) in o:
		if a[0] >= x and a[1] >= y and (a[2] >= z):
			total += 1
			a[0] -= x
			a[1] -= y
			a[2] -= z
	print(total)


n = int(input())
for i in range(n):
	a = map(int, input().split())
	l = list(a)
	l.sort()
	k = 0
	if max(l) > 0:
		l[2] -= 1
		k += 1
		if l[1] > 0:
			l[1] -= 1
			k += 1
		if l[0] > 0:
			l[0] -= 1
			k += 1
		if l[2] > 0 and l[1] > 0:
			l[2] -= 1
			l[1] -= 1
			k += 1
		if l[2] > 0 and l[0] > 0:
			l[2] -= 1
			l[0] -= 1
			k += 1
		if l[1] > 0 and l[0] > 0:
			k += 1
			l[1] -= 1
			l[0] -= 1
		if l[1] > 0 and l[0] > 0 and (l[2] > 0):
			k += 1
	print(k)


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)


def t1(t):
	if t[0] > 0 and t[1] > 0:
		t[0] -= 1
		t[1] -= 1
		return 1
	return 0

def t2(t):
	if t[0] > 0 and t[2] > 0:
		t[0] -= 1
		t[2] -= 1
		return 1
	return 0

def t3(t):
	if t[1] > 0 and t[2] > 0:
		t[1] -= 1
		t[2] -= 1
		return 1
	return 0
c = int(input())
for i in range(0, c):
	cnt = 0
	abc = list(map(int, input().split()))
	if abc[0] > 0:
		abc[0] -= 1
		cnt += 1
	if abc[1] > 0:
		abc[1] -= 1
		cnt += 1
	if abc[2] > 0:
		abc[2] -= 1
		cnt += 1
	l = [0, 0, 0, 0, 0, 0]
	k = []
	tmp = [abc[0], abc[1], abc[2]]
	l[0] = t1(tmp) + t2(tmp) + t3(tmp)
	k.append(tmp)
	tmp = [abc[0], abc[1], abc[2]]
	l[1] = t1(tmp) + t3(tmp) + t2(tmp)
	k.append(tmp)
	tmp = [abc[0], abc[1], abc[2]]
	l[2] = t2(tmp) + t1(tmp) + t3(tmp)
	k.append(tmp)
	tmp = [abc[0], abc[1], abc[2]]
	l[3] = t2(tmp) + t3(tmp) + t1(tmp)
	k.append(tmp)
	tmp = [abc[0], abc[1], abc[2]]
	l[4] = t3(tmp) + t1(tmp) + t2(tmp)
	k.append(tmp)
	tmp = [abc[0], abc[1], abc[2]]
	l[5] = t3(tmp) + t2(tmp) + t1(tmp)
	k.append(tmp)
	j = l.index(max(l))
	abc = k[j]
	cnt += l[j]
	if abc[0] > 0 and abc[1] > 0 and (abc[2] > 0):
		cnt += 1
	print(cnt)


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


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


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	d = 0
	if a > 0:
		d = d + 1
		a = a - 1
	if b > 0:
		d = d + 1
		b = b - 1
	if c > 0:
		d = d + 1
		c = c - 1
	if a >= 3 and b >= 3 and (c >= 3):
		d = d + 4
		print(d)
		continue
	if a >= 2 and b >= 2 and (c >= 2):
		d = d + 3
		print(d)
		continue
	if min(a, b, c) == 1 and max(a, b, c) >= 2:
		d = d + 2
		print(d)
		continue
	if min(a, b, c) == 1 and max(a, b, c) == 1:
		d = d + 1
		print(d)
		continue
	if min(a, b, c) == 0:
		if a != 0 and c != 0:
			d = d + 1
			print(d)
			continue
		elif a != 0 and b != 0:
			d = d + 1
			print(d)
			continue
		elif b != 0 and c != 0:
			d = d + 1
			print(d)
			continue
		else:
			print(d)
			continue


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] >= 4:
		print(7)
	else:
		res = 0
		if a[2]:
			res += 1
			a[2] -= 1
		if a[1]:
			res += 1
			a[1] -= 1
		if a[0]:
			res += 1
			a[0] -= 1
		if a[1] and a[2]:
			a[1] -= 1
			a[2] -= 1
			res += 1
		if a[0] and a[1]:
			res += 1
			a[0] -= 1
			a[1] -= 1
		if a[0] and a[2]:
			a[0] -= 1
			a[2] -= 1
			res += 1
		if a[0] and a[1] and a[2]:
			res += 1
			a[1] -= 1
			a[1] -= 1
			a[0] -= 1
		print(res)


T = int(input())

def getmax(r, g, b):
	count = 0
	for i in range(7):
		if i == 0 and r:
			r -= 1
			count += 1
		if i == 1 and g:
			g -= 1
			count += 1
		if i == 2 and b:
			b -= 1
			count += 1
		if i == 3 and r and g:
			r -= 1
			g -= 1
			count += 1
		if i == 4 and r and b:
			r -= 1
			b -= 1
			count += 1
		if i == 5 and b and g:
			b -= 1
			g -= 1
			count += 1
		if i == 6 and r and g and b:
			count += 1
	return count
for t in range(T):
	(r, g, b) = map(int, input().split())
	if b > r and b > g:
		print(getmax(r, b, g))
	else:
		print(getmax(r, g, b))


t = int(input())
for i in range(t):
	temp = sorted([int(x) for x in input().split()])[::-1]
	total = 0
	for j in range(3):
		if temp[j] > 0:
			total += 1
			temp[j] -= 1
	a = temp[0]
	b = temp[1]
	c = temp[2]
	if a > 0 and b > 0:
		total += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		total += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		total += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		total += 1
	print(total)


for i in range(int(input())):
	(p, q, r) = map(int, input().split())
	c = max(p, q, r)
	a = min(p, q, r)
	b = p + q + r - (a + c)
	count = 0
	if a > 0:
		count = count + 1
		a = a - 1
	if b > 0:
		count = count + 1
		b = b - 1
	if c > 0:
		count = count + 1
		c = c - 1
	if c > 0 and b > 0:
		count = count + 1
		c = c - 1
		b = b - 1
	if a > 0 and c > 0:
		count = count + 1
		a = a - 1
		c = c - 1
	if b > 0 and a > 0:
		count = count + 1
		a = a - 1
		b = b - 1
	if a > 0 and b > 0 and (c > 0):
		count = count + 1
	print(count)


import itertools
T = int(input())
for t in range(T):
	ans = -1
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	K = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	for i in range(8):
		for lis in itertools.combinations(K, i):
			aa = 0
			bb = 0
			cc = 0
			for l in lis:
				aa += l[0]
				bb += l[1]
				cc += l[2]
			if aa <= a and bb <= b and (cc <= c):
				ans = max(ans, i)
	print(ans)


n = int(input())

def f(a, b, ans):
	z1 = min(a, b)
	if z1 > 0:
		a -= 1
		b -= 1
		z1 = 1
		ans += 1
		return (a, b, ans)
	return (a, b, ans)

def f2(a, b, c):
	a1 = 0
	(a, b, a1) = f(a, b, a1)
	(b, c, a1) = f(b, c, a1)
	(c, a, a1) = f(a, c, a1)
	z4 = min(a, b, c)
	ans = 0
	if z4 > 0:
		ans = 1
	ans += a1
	return ans
for i in range(n):
	(a, b, c) = map(int, input().split(' '))
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	z = 0
	d = {}
	a1 = f2(a, b, c)
	a2 = f2(b, c, a)
	a3 = f2(a, c, b)
	a4 = f2(b, a, c)
	a5 = f2(c, a, b)
	a6 = f2(c, b, a)
	print(ans + max(a1, a2, a3, a4, a5, a6))


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x > 4:
		x = 4
	if y > 4:
		y = 4
	if z > 4:
		z = 4
	p = sorted([x, y, z])
	if p[2] == 0:
		print(0)
	elif p[0] == 0:
		print(min(p[1] + 1, 3))
	elif p[0] == 1:
		print(min(p[1] + 2, 4))
	elif p[0] == 2:
		if p[2] == 2:
			print(4)
		else:
			print(5)
	elif p[0] == 3:
		print(6)
	else:
		print(7)


for q in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	n = 1
	if a > 0:
		n += 1
		a -= 1
	if b > 0:
		n += 1
		b -= 1
	if c > 0:
		n += 1
		c -= 1
	if a > b and a > c:
		if a > 0 and c > 0:
			n += 1
			c -= 1
			a -= 1
		if a > 0 and b > 0:
			n += 1
			b -= 1
			a -= 1
		if b > 0 and c > 0:
			n += 1
			c -= 1
			b -= 1
	elif b > a and b > c:
		if b > 0 and c > 0:
			n += 1
			c -= 1
			b -= 1
		if a > 0 and b > 0:
			n += 1
			b -= 1
			a -= 1
		if a > 0 and c > 0:
			n += 1
			c -= 1
			a -= 1
	else:
		if a > 0 and c > 0:
			n += 1
			c -= 1
			a -= 1
		if c > 0 and b > 0:
			n += 1
			b -= 1
			c -= 1
		if b > 0 and a > 0:
			n += 1
			a -= 1
			b -= 1
	if a > 0 and b > 0 and (c > 0):
		n += 1
		c -= 1
		b -= 1
		a -= 1
	print(n - 1)


t = int(input().strip())
for test in range(t):
	dishes = list(reversed(sorted([int(i) for i in input().split()])))
	counter = 0
	for (i, dish) in enumerate(dishes):
		if dish > 0:
			dishes[i] -= 1
			counter += 1
	if counter <= 1:
		print(counter)
		continue
	if dishes[2] > 0 and dishes[0] > 0:
		counter += 1
		dishes[-1] -= 1
		dishes[0] -= 1
	if dishes[0] > 0 and dishes[1] > 0:
		counter += 1
		dishes[0] -= 1
		dishes[1] -= 1
	if dishes[-1] > 0 and dishes[-2] > 0:
		counter += 1
		dishes[-1] -= 1
		dishes[-2] -= 1
	if sorted(dishes)[0] > 0:
		counter += 1
	print(counter)


from math import factorial
for t in range(int(input())):
	(a, b, c) = [int(j) for j in input().split()]
	d = [[a, 0], [b, 1], [c, 2]]
	p = ['a', 'b', 'c', 'ab', 'bc', 'ca', 'abc']
	ans = 0
	for i in range(3):
		if d[i][0] > 0:
			d[i][0] -= 1
			ans += 1
	d = sorted(d)
	for i in range(3, 0, -1):
		if d[3 - i - 1][0] > 0 and d[3 - i - 2][0] > 0:
			ans += 1
			d[3 - i - 1][0] -= 1
			d[3 - i - 2][0] -= 1
	for i in range(3):
		if d[i][0] > 0:
			continue
		else:
			break
	else:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort()
	c = [(0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
	co = 0
	for ci in c:
		if l[0] - ci[0] >= 0 and l[1] - ci[1] >= 0 and (l[2] - ci[2] >= 0):
			l[0] -= ci[0]
			l[1] -= ci[1]
			l[2] -= ci[2]
			co += 1
	print(co)


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	l = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 0], [1, 1, 1]]
	count = 0
	for i in l:
		if a >= i[0] and b >= i[1] and (c >= i[2]):
			count += 1
			a -= i[0]
			b -= i[1]
			c -= i[2]
	print(count)


t = int(input())
for _ in range(t):
	(a, b, c) = sorted(map(int, input().split()))
	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 * c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b * c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a * b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a * b * c > 0:
		ans += 1
	print(ans)


import sys
input = sys.stdin.readline
serve = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
t = int(input())
for _ in range(t):
	cnt = list(map(int, input().split()))
	ans = 0
	for i in range(len(serve)):
		if i == 3:
			cnt.sort(reverse=True)
		poss = True
		for idx in serve[i]:
			if cnt[idx] <= 0:
				poss = False
		if poss:
			ans += 1
			for idx in serve[i]:
				cnt[idx] -= 1
	print(ans)


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	(a, b, c) = map(int, stdin.readline().split())
	xx = [a, b, c]
	xx.sort()
	(a, b, c) = (xx[2], xx[1], xx[0])
	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 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	stdout.write('{}\n'.format(ans))


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	print(factors)
	if len(factors) == 2:
		return True
	else:
		return False

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def Sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def minimum_integer_not_in_list(a):
	b = max(a)
	if b < 1:
		return 1
	A = set(a)
	B = set(range(1, b + 1))
	D = B - A
	if len(D) == 0:
		return b + 1
	else:
		return min(D)

def solve(a, b, c):
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		ans += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		ans += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		a -= 1
		b -= 1
		c -= 1
		ans += 1
	return ans

def solution():
	for i in range(Int()):
		(a, b, c) = Mint()
		ans = 0
		ans = max(ans, solve(a, b, c))
		ans = max(ans, solve(a, c, b))
		ans = max(ans, solve(b, c, a))
		ans = max(ans, solve(c, a, b))
		ans = max(ans, solve(b, a, c))
		ans = max(ans, solve(c, b, a))
		print(ans)
solution()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	e = sorted([a, b, c])
	s = 0
	for i in range(8):
		x = str(bin(i))[2:].rjust(3, '0')
		x = list(map(int, x))
		if all((e[j] >= x[j] for j in range(3))):
			for i in range(3):
				e[i] -= x[i]
			s += max(x)
	print(s)


for pratyush in range(int(input())):
	(a, b, c) = map(int, input().split())
	k = 0
	while k < 7:
		if a != 0:
			(k, a) = (k + 1, a - 1)
		if b != 0:
			(k, b) = (k + 1, b - 1)
		if c != 0:
			(k, c) = (k + 1, c - 1)
		if a == 0 and b == 0 or (c == 0 and b == 0) or (a == 0 and c == 0) or (a == 0 and b == 0 and (c == 0)):
			break
		if a == 0 or b == 0 or c == 0:
			(k, a, b, c) = (k + 1, 0, 0, 0)
			break
		if a == 1 and b == 1 and (c == 1):
			(k, a, b, c) = (k + 1, 0, 0, 0)
			break
		if a == 1 or b == 1 or c == 1:
			(k, a, b, c) = (k + 2, 0, 0, 0)
			break
		if a == 2 and b >= 2 and (c >= 2) or (c >= 2 and b == 2 and (a >= 2)) or (c == 2 and a >= 2 and (b >= 2)):
			(k, a, b, c) = (k + 3, 0, 0, 0)
			break
		if a >= 2 and b >= 2 and (c >= 2):
			(k, a, b, c) = (k + 4, 0, 0, 0)
			break
	print(k)


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)


n = int(input())
l2 = []
for i in range(n):
	c = 0
	l1 = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	l = list(map(int, input().split()))
	l.sort()
	for j in l1:
		if l[0] - j[0] >= 0 and l[1] - j[1] >= 0 and (l[2] - j[2] >= 0):
			l[0] = l[0] - j[0]
			l[1] = l[1] - j[1]
			l[2] = l[2] - j[2]
			c = c + 1
	l2.append(c)
for i in l2:
	print(i)


import sys

def rr():
	return sys.stdin.readline().rstrip()
rp = print

def print(*args, **kwargs):
	rp('DBG:# ', *args, **kwargs, file=sys.stderr)

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))

def rrle():
	return (line.rstrip() for line in sys.stdin.readlines())

def rrtl():
	return [tuple(map(int, l.split())) for l in rrle()]
from collections import defaultdict

def mus(d=lambda : 0):
	return defaultdict(lambda : defaultdict(d))

def dd0(d=lambda : 0):
	return defaultdict(d)

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def fltn(a):
	(i for sub in a for i in sub)

def yn(x):
	return 'YES' if x else 'NO'

def cpc(arr):
	return zip(arr, arr[1:])
from itertools import accumulate
from itertools import groupby
from itertools import permutations

def grp(x, key=None):
	return ((i, sum((1 for _ in g))) for (i, g) in groupby(x, key=key))
import math

def rnar():
	return (*rrl(), rrl())

def rn():
	return (*rrl(),)

def dpp(a, b=''):
	print('#| {} |#:^ {} ^:'.format(a, b))

def str_join(i, sep=' '):
	return sep.join(map(str, i))
MOD17 = 10 ** 9 + 7

def read():
	return (*rrl(),)

def solve(a, b, c):
	(a, b, c) = sorted((a, b, c), reverse=True)
	dishs = 0
	if a:
		dishs += 1
		a -= 1
		print('A')
	if b:
		dishs += 1
		b -= 1
		print('B')
	if c:
		dishs += 1
		c -= 1
		print('C')
	if a and b:
		dishs += 1
		a -= 1
		b -= 1
		print('AB')
	if a and c:
		dishs += 1
		a -= 1
		c -= 1
		print('AC')
	if b and c:
		dishs += 1
		b -= 1
		c -= 1
		print('BC')
	if a and b and c:
		dishs += 1
		a -= 1
		b -= 1
		c -= 1
		print('ABC')
	ans = dishs
	return ans
test_count = rri()
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	rp(result)


t = int(input())
while t != 0:
	l = []
	c = 0
	l = [int(x) for x in input().split()]
	l = [x for x in l if x != 0]
	c += len(l)
	l = [x - 1 for x in l if x != 0]
	l = [x for x in l if x != 0]
	if len(l) == 3:
		d = 0
		for x in l:
			if x == 1:
				d += 1
		if d == 3:
			c += 1
		elif d == 2 or d == 1:
			c += 2
		else:
			c += 3
		l = [max(x - 2, 0) for x in l]
	elif len(l) == 2:
		c += 1
		l = [x - 1 for x in l]
	l = [x for x in l if x != 0]
	if len(l) == 3:
		c += 1
	print(c)
	t -= 1


def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split(' '))
		r = 0
		if a >= 1:
			a -= 1
			r += 1
		if b >= 1:
			b -= 1
			r += 1
		if c >= 1:
			c -= 1
			r += 1
		l = [a, b, c]
		l.sort(reverse=True)
		if l[0] >= 2:
			if l[1] >= 1 and l[2] >= 1:
				l[0] -= 2
				l[1] -= 1
				l[2] -= 1
				r += 2
			elif l[1] >= 1:
				l[0] -= 1
				l[1] -= 1
				r += 1
		elif l[0] >= 1 and l[1] >= 1:
			l[0] -= 1
			l[1] -= 1
			r += 1
		if l[1] >= 1 and l[2] >= 1:
			l[1] -= 1
			l[2] -= 1
			r += 1
		if l[0] >= 1 and l[1] >= 1 and (l[2] >= 1):
			r += 1
		print(r)
main()


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (a, b, c) in Query:
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	A = [a, b, c]
	A.sort()
	if A[0] >= 2:
		ans += 3
		A[0] -= 2
		A[1] -= 2
		A[2] -= 2
	elif A[0] == 1:
		if A[2] >= 2:
			A[0] -= 1
			A[1] -= 1
			A[2] -= 2
			ans += 2
		else:
			A[0] -= 1
			A[1] -= 1
			ans += 1
	elif A[1] >= 1:
		A[1] -= 1
		A[2] -= 1
		ans += 1
	if min(A) > 0:
		ans += 1
	print(ans)


things = [(1, 0, 0), (1, 1, 0), (1, 0, 1), (0, 1, 0), (0, 1, 1), (0, 0, 1), (1, 1, 1)]

def sub(a, b):
	return (a[0] - b[0], a[1] - b[1], a[2] - b[2])

def less_zero(a):
	return any((x < 0 for x in a))
task_number = int(input())
for _ in range(task_number):
	(a, b, c) = map(int, input().split())
	(a, b, c) = sorted([a, b, c], key=lambda x: -x)
	result = 0
	for t in things:
		diff = sub((a, b, c), t)
		if not less_zero(diff):
			result += 1
			(a, b, c) = diff
	print(result)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		result = 0
		if a:
			result += 1
			a -= 1
		if b:
			result += 1
			b -= 1
		if c:
			result += 1
			c -= 1
		if a and c:
			result += 1
			a -= 1
			c -= 1
		if a and b:
			result += 1
			a -= 1
			b -= 1
		if b and c:
			result += 1
			b -= 1
			c -= 1
		if a and b and c:
			result += 1
		print(result)


def solve():
	ans = 0
	(a, b, c) = map(int, input().split())
	x = [a, b, c]
	x.sort()
	if x[0] > 0:
		x[0] -= 1
		ans += 1
	if x[1] > 0:
		x[1] -= 1
		ans += 1
	if x[2] > 0:
		x[2] -= 1
		ans += 1
	if x[0] > 0 and x[2] > 0:
		x[0] -= 1
		x[2] -= 1
		ans += 1
	if x[1] > 0 and x[2] > 0:
		x[1] -= 1
		x[2] -= 1
		ans += 1
	if x[0] > 0 and x[1] > 0:
		x[0] -= 1
		x[1] -= 1
		ans += 1
	if x[0] > 0 and x[1] > 0 and (x[2] > 0):
		x[0] -= 1
		x[1] -= 1
		x[2] -= 1
		ans += 1
	print(ans)
Q = int(input())
while Q > 0:
	solve()
	Q -= 1


t = int(input())
for i in range(t):
	dishes = list(map(int, input().split()))
	sol = 0
	for (i, dish) in enumerate(dishes):
		if dish > 0:
			dishes[i] -= 1
			sol += 1
	dishes.sort(reverse=True)
	for i in range(len(dishes)):
		for j in range(i + 1, len(dishes)):
			if dishes[i] > 0 and dishes[j] > 0:
				sol += 1
				dishes[i] -= 1
				dishes[j] -= 1
	if dishes[0] > 0 and dishes[1] > 0 and (dishes[2] > 0):
		sol += 1
	print(sol)


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	sets = [(0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
	d = 0
	(a, b, c) = [i for i in sorted([a, b, c])]
	for i in sets:
		if a >= i[0] and b >= i[1] and (c >= i[2]):
			d += 1
			a -= i[0]
			b -= i[1]
			c -= i[2]
	print(d)


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


n = int(input())
ar = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
ar1 = [[1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
ar2 = [[1, 1, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]
ar3 = [[1, 0, 1], [1, 1, 0], [0, 1, 1], [1, 1, 1]]
ar4 = [[1, 0, 1], [0, 1, 1], [1, 1, 0], [1, 1, 1]]
ar5 = [[0, 1, 1], [1, 1, 0], [1, 0, 1], [1, 1, 1]]
ar6 = [[0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
for z in range(n):
	cnt = 0
	amount = list(map(int, input().split()))
	for j in ar:
		if amount[0] - j[0] >= 0 and amount[1] - j[1] >= 0 and (amount[2] - j[2] >= 0):
			amount[0] -= j[0]
			amount[1] -= j[1]
			amount[2] -= j[2]
			cnt += 1
	a = [ar1, ar2, ar3, ar4, ar5, ar6]
	mxcnt = 0
	for ari in a:
		cntNow = 0
		nowamount = amount.copy()
		for j in ari:
			if nowamount[0] - j[0] >= 0 and nowamount[1] - j[1] >= 0 and (nowamount[2] - j[2] >= 0):
				nowamount[0] -= j[0]
				nowamount[1] -= j[1]
				nowamount[2] -= j[2]
				cntNow += 1
		mxcnt = max(mxcnt, cntNow)
	print(cnt + mxcnt)


q = int(input())
while q:
	q += -1
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	if l[0] == 0:
		if l[1] == 0:
			if l[2] == 0:
				ans = 0
			else:
				ans = 1
		elif l[1] == 1:
			ans = 2
		else:
			ans = 3
	elif l[0] == 1:
		if l[1] == 1:
			ans = 3
		else:
			ans = 4
	elif l[0] == 2:
		if l[1] == 2:
			if l[2] == 2:
				ans = 4
			else:
				ans = 5
		else:
			ans = 5
	elif l[0] == 3:
		ans = 6
	else:
		ans = 7
	print(ans)


from sys import stdin, stdout
import traceback
from itertools import chain, combinations
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def powerset(iterable, skip_empty=False):
	s = list(iterable)
	ret = chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))
	if skip_empty:
		next(ret)
	return ret

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:
	cache = {}

	@classmethod
	def input(cls):
		s = cls()
		return s

	def solve(self):
		(a, b, c) = reads()
		maxv = 0
		for (x, v) in self.cache.items():
			if x[0] <= a and x[1] <= b and (x[2] <= c) and (v > maxv):
				maxv = v
		return maxv

	@classmethod
	def build(cls):
		cache = {}
		candidates = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
		for s in powerset(candidates, True):
			sums = tuple(map(sum, zip(*s)))
			cache[sums] = len(s)
		cls.cache = cache
try:
	Sol.build()
	for _ in range(int(read())):
		writeln(Sol.input().solve())
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ans = 0
	for i in range(3):
		if l[i] > 0:
			l[i] -= 1
			ans += 1
	for i in range(3):
		for j in range(i):
			if l[i] > 0 and l[j] > 0:
				ans += 1
				l[i] -= 1
				l[j] -= 1
	if min(l) > 0:
		ans += 1
	print(ans)


def checker(a, b, c):
	if c == 0:
		return 0
	elif a == 0:
		return min(b + 1, 3)
	elif a == 1:
		return min(b + 2, 4)
	elif a == 2:
		return 4 if c == 2 else 5
	elif a == 3:
		return 6
	return 7
for _ in range(int(input())):
	(A, B, C) = [int(i) for i in input().split()]
	lst = sorted([A, B, C])
	print(checker(lst[0], lst[1], lst[2]))


def solve(a, b, c):
	res = 0
	for bit in range(1 << 7):
		cnt = [0, 0, 0]
		temp_set = 0
		for j in range(1, 8):
			if bit & 1 << j - 1:
				for k in range(3):
					if j & 1 << k:
						cnt[k] += 1
				temp_set += 1
		if a >= cnt[0] and b >= cnt[1] and (c >= cnt[2]):
			res = max(temp_set, res)
	return res
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	print(solve(a, b, c))


def main():
	d = {0: 0, 1: 1, 2: 1, 3: 1, 4: 1, 6: 2, 7: 2, 8: 2, 9: 2, 12: 3, 13: 3, 14: 3, 18: 3, 19: 3, 24: 3, 31: 3, 32: 3, 33: 3, 34: 3, 37: 4, 38: 4, 39: 4, 43: 4, 44: 4, 49: 4, 62: 4, 63: 5, 64: 5, 68: 5, 69: 5, 74: 5, 93: 6, 94: 6, 99: 6, 124: 7}
	for _ in range(int(input())):
		(a, b, c) = sorted((min(int(s), 4) for s in input().split()))
		print(d[a * 25 + b * 5 + c])
main()


for test in range(int(input())):
	(x, y, z) = map(int, input().split())
	a = max(x, y, z)
	c = min(x, y, z)
	s = x + y + z
	b = s - a - c
	ca = 0
	if a > 0:
		ca += 1
		a -= 1
	if b > 0:
		ca += 1
		b -= 1
	if c > 0:
		ca += 1
		c -= 1
	if a > 0 and b > 0:
		ca += 1
		a -= 1
		b -= 1
	if b > 0 and c > 0:
		ca += 1
		b -= 1
		c -= 1
	if a > 0 and c > 0:
		ca += 1
		a -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ca += 1
	print(ca)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	A = [a, b, c]
	A.sort()
	Ans = 0
	if A[0] == 3:
		print(6)
	elif A[0] == 2 and A[1] == 2 and (A[2] > 2):
		print(5)
	elif A[0] == 2 and A[1] > 2:
		print(5)
	elif A[0] == 2 and A[1] == 2 and (A[2] == 2):
		print(4)
	elif A[0] == 1 and A[1] > 1:
		print(4)
	elif A[0] == 1 and A[1] == 1:
		print(3)
	elif A[0] == 0 and A[1] == 0 and (A[2] == 0):
		print(0)
	elif A[0] == 0 and A[1] == 0 and (A[2] > 0):
		print(1)
	elif A[0] == 0 and A[1] == 1 and (A[2] >= 1):
		print(2)
	elif A[0] == 0 and A[1] > 1:
		print(3)
	else:
		print(7)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	f = 0
	if b < c:
		(b, c) = (c, b)
	if a > 0:
		f += 1
		a -= 1
	if b > 0:
		f += 1
		b -= 1
	if c > 0:
		f += 1
		c -= 1
	if a > 0 and b > 0:
		f += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		f += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		f += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		f += 1
		a -= 1
		b -= 1
		c -= 1
	print(f)


import sys
import math

def main():
	for _ in range(int(sys.stdin.readline())):
		(a, b, c) = map(int, sys.stdin.readline().split())
		l = [a, b, c]
		l.sort()
		a = l[-1]
		b = l[-2]
		c = l[-3]
		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 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			ans += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			ans += 1
			c -= 1
			b -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
			a -= 1
			b -= 1
			c -= 1
		print(ans)
main()


for _ in range(int(input())):
	lis = list(map(int, input().split()))
	output = 0
	for i in range(3):
		if lis[i] > 0:
			lis[i] -= 1
			output += 1
	i = 2
	while i > -1:
		if lis[i] == 0:
			lis.remove(lis[i])
		i -= 1
	if len(lis) == 0:
		print(output)
		continue
	lis.sort(reverse=True)
	if len(lis) == 1:
		print(output)
		continue
	if len(lis) == 2:
		print(output + 1)
		continue
	if len(lis) == 3:
		if lis[0] and lis[1]:
			output += 1
			lis[0] -= 1
			lis[1] -= 1
		if lis[1] and lis[2]:
			output += 1
			lis[1] -= 1
			lis[2] -= 1
		if lis[2] and lis[0]:
			output += 1
			lis[0] -= 1
			lis[2] -= 1
		if lis[0] > 0 and lis[1] > 0 and (lis[2] > 0):
			print(7)
		else:
			print(output)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	r = []
	m = a[0]
	n = a[1]
	k = a[2]
	l = [m, n, k, m, k, n, n, m, k, n, k, m, k, m, n, k, n, m]
	for i in range(0, 16, 3):
		c = 0
		m = l[i]
		n = l[i + 1]
		k = l[i + 2]
		if m > 0:
			m -= 1
			c += 1
		if n > 0:
			n -= 1
			c += 1
		if k > 0:
			k -= 1
			c += 1
		if m > 0 and n > 0:
			m -= 1
			n -= 1
			c += 1
		if m > 0 and k > 0:
			m -= 1
			k -= 1
			c += 1
		if k > 0 and n > 0:
			k -= 1
			n -= 1
			c += 1
		if m > 0 and n > 0 and (k > 0):
			m -= 1
			n -= 1
			k -= 1
			c += 1
		r.append(c)
	print(max(r))


from itertools import permutations
orders = [list(permutations([(1, 0, 0), (0, 1, 0), (0, 0, 1)])), list(permutations([(1, 1, 0), (0, 1, 1), (1, 0, 1)])), [(1, 1, 1)]]

def get_customer_nums(a, b, c):
	products = [a, b, c]
	max_count = 0
	for i in range(6):
		for j in range(6):
			a_count = a
			b_count = b
			c_count = c
			count = 0
			for order in orders[0][i]:
				if order[0]:
					if a_count >= 1:
						a_count -= 1
					else:
						continue
				if order[1]:
					if b_count >= 1:
						b_count -= 1
					else:
						continue
				if order[2]:
					if c_count >= 1:
						c_count -= 1
					else:
						continue
				count += 1
			for order in orders[1][j]:
				if order[0]:
					if a_count >= 1:
						a_count -= 1
					else:
						continue
				if order[1]:
					if b_count >= 1:
						b_count -= 1
					else:
						continue
				if order[2]:
					if c_count >= 1:
						c_count -= 1
					else:
						continue
				count += 1
			for order in orders[2]:
				if order[0]:
					if a_count >= 1:
						a_count -= 1
					else:
						continue
				if order[1]:
					if b_count >= 1:
						b_count -= 1
					else:
						continue
				if order[2]:
					if c_count >= 1:
						c_count -= 1
					else:
						continue
				count += 1
			max_count = max(count, max_count)
	return max_count
t = int(input())
for _ in range(t):
	(a, b, c) = tuple(map(int, input().split(' ')))
	print(get_customer_nums(a, b, c))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for j in range(3):
		if l[j] != 0:
			c += 1
			l[j] -= 1
	if l[2] >= 1 and l[0] >= 1:
		c += 1
		l[2] -= 1
		l[0] -= 1
	if l[2] >= 1 and l[1] >= 1:
		c += 1
		l[2] -= 1
		l[1] -= 1
	if l[1] >= 1 and l[0] >= 1:
		c += 1
		l[1] -= 1
		l[0] -= 1
	if l[0] != 0 and l[1] != 0 and (l[2] != 0):
		c += 1
	print(c)


t = int(input())
for i in range(t):
	arr = list(map(int, input().rstrip().split()))
	arr.sort()
	(a, b, c) = (arr[2], arr[1], arr[0])
	n = 4
	if a >= n and b >= n and (c >= n):
		print(7)
		continue
	cnt = 0
	if a > 0:
		a = a - 1
		cnt += 1
	if b > 0:
		b -= 1
		cnt += 1
	if c > 0:
		c -= 1
		cnt += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		cnt += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		cnt += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		cnt += 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
	print(cnt)


for _ in range(int(input())):
	ar = list(map(int, input().split()))
	count = 0
	for i in range(3):
		if ar[i] != 0:
			count += 1
			ar[i] -= 1
	ar.sort(reverse=True)
	for i in range(1, 3):
		if ar[i] != 0 and ar[0] != 0:
			count += 1
			ar[0] -= 1
			ar[i] -= 1
	if ar[1] != 0 and ar[2] != 0:
		count += 1
		ar[1] -= 1
		ar[2] -= 1
	if min(ar) != 0:
		count += 1
	print(count)


def ii():
	return int(input())

def ai():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())
for _ in range(ii()):
	lst = ai()
	ans = 0
	for (ind, ele) in enumerate(lst):
		if ele:
			ans += 1
			lst[ind] -= 1
	lst.sort(reverse=True)
	perm = [[0, 1], [0, 2], [1, 2]]
	for i in range(3):
		a = perm[i][0]
		b = perm[i][1]
		if lst[a] and lst[b]:
			ans += 1
			lst[a] -= 1
			lst[b] -= 1
	if 0 not in lst:
		ans += 1
	print(ans)


t = eval(input())
while t:
	a = list(map(int, input().split()))
	ans = 0
	for i in range(len(a)):
		if a[i] > 0:
			ans += 1
			a[i] -= 1
	cntZero = 0
	for i in a:
		if i == 0:
			cntZero += 1
	if cntZero == 1:
		ans += 1
	elif cntZero == 0:
		mn = 15
		for i in a:
			mn = min(mn, i)
		if mn >= 3:
			ans += 4
		elif mn == 2:
			ans += 3
		elif mn == 1:
			mx = 0
			for j in a:
				mx = max(mx, j)
			if mx == 1:
				ans += 1
			else:
				ans += 2
	print(ans)
	t -= 1


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		dp = [[1]]
		for i in range(2, 8):
			for j in range(len(dp)):
				dp.append(dp[j] + [i])
			dp.append([i])
		ans = 0
		for k in dp:
			(q, w, e) = (a, b, c)
			for x in k:
				q -= x & 1 != 0
				w -= x & 2 != 0
				e -= x & 4 != 0
			if min(q, w, e) >= 0:
				ans = max(ans, len(k))
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys

def solve():
	input = sys.stdin.readline
	t = int(input())
	Ans = []
	for _ in range(t):
		num = [int(i) for i in input().split()]
		count = 0
		num.sort(reverse=True)
		for i in range(3):
			if num[i] > 0:
				count += 1
				num[i] -= 1
		for i in range(2):
			for j in range(i + 1, 3):
				if num[i] > 0 and num[j] > 0:
					count += 1
					num[i] -= 1
					num[j] -= 1
		for (i, a) in enumerate(num):
			if a == 0:
				break
		else:
			count += 1
		Ans.append(count)
	for a in Ans:
		print(a)
	return 0
solve()


def solved(a, b, c):
	arr = [a, b, c]
	arr.sort(reverse=True)
	return (arr[0], arr[1], arr[2])

def main():
	(a, b, c) = map(int, input().split())
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	(a, b, c) = solved(a, b, c)
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		ans += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		ans += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
	return
test()


from bisect import *
from math import *
mod = 10 ** 9 + 7
t = int(input())
for i in range(t):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		arr = sorted([a, b, c])
		ans = 0
		if arr[0] == 0:
			if arr[1] == 0:
				if arr[2] >= 1:
					ans += 1
			elif arr[1] == 1:
				ans += 2
			elif arr[1] >= 2:
				ans += 3
		elif arr[0] == 1:
			ans += 1
			if arr[1] == 1:
				ans += 2
			elif arr[1] >= 2:
				ans += 3
		elif arr[0] == 2:
			if arr[2] >= 3:
				ans += 5
			elif arr[2] == 2:
				ans += 4
		elif arr[0] == 3:
			ans += 6
		print(ans)


n = int(input())
for test in range(n):
	nums = list(map(int, input().split()))
	res = 0
	if nums[0] > 0:
		res += 1
		nums[0] -= 1
	if nums[1] > 0:
		res += 1
		nums[1] -= 1
	if nums[2] > 0:
		res += 1
		nums[2] -= 1
	nums.sort(reverse=True)
	if nums[0] > 0 and nums[1] > 0:
		res += 1
		nums[1] -= 1
		nums[0] -= 1
	if nums[0] > 0 and nums[2] > 0:
		res += 1
		nums[0] -= 1
		nums[2] -= 1
	if nums[2] > 0 and nums[1] > 0:
		res += 1
		nums[2] -= 1
		nums[1] -= 1
	if nums[0] > 0 and nums[1] > 0 and (nums[2] > 0):
		res += 1
	print(res)


for j in range(int(input())):
	(c, b, a) = sorted(map(int, input().split()))
	count = 0
	if a > 0:
		a = a - 1
		count = count + 1
	else:
		pass
	if b > 0:
		b = b - 1
		count = count + 1
	else:
		pass
	if c > 0:
		c = c - 1
		count = count + 1
	else:
		pass
	if a > 0 and b > 0:
		a = a - 1
		b = b - 1
		count = count + 1
	else:
		pass
	if a > 0 and c > 0:
		a = a - 1
		c = c - 1
		count = count + 1
	else:
		pass
	if b > 0 and c > 0:
		b = b - 1
		c = c - 1
		count = count + 1
	else:
		pass
	if a > 0 and b > 0 and (c > 0):
		count = count + 1
	else:
		pass
	print(count)


from sys import exit

def iis():
	return map(int, input().split())

def ii():
	return int(input())

def liis():
	return list(map(int, input().split()))
t = ii()
for _ in range(t):
	(a, b, c) = iis()
	a = sorted([a, b, c])[::-1]
	(a, b, c) = (a[0], a[1], a[2])
	count = 0
	if a >= 1:
		count += 1
		a -= 1
	if b >= 1:
		count += 1
		b -= 1
	if c >= 1:
		count += 1
		c -= 1
	if a >= 1 and b >= 1:
		count += 1
		a -= 1
		b -= 1
	if a >= 1 and c >= 1:
		count += 1
		a -= 1
		c -= 1
	if b >= 1 and c >= 1:
		count += 1
		b -= 1
		c -= 1
	if b >= 1 and a >= 1 and (c >= 1):
		count += 1
	print(count)


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


for j in range(int(input())):
	(n, m, k) = [int(s) for s in input().split()]
	ans = 0
	if n != 0:
		n -= 1
		ans += 1
	if m != 0:
		m -= 1
		ans += 1
	if k != 0:
		k -= 1
		ans += 1
	(n, m, k) = (max(n, max(m, k)), m + n + k - max(n, max(m, k)) - min(n, min(m, k)), min(n, min(m, k)))
	if n != 0 and m != 0:
		n -= 1
		m -= 1
		ans += 1
	if n != 0 and k != 0:
		n -= 1
		k -= 1
		ans += 1
	if k != 0 and m != 0:
		k -= 1
		m -= 1
		ans += 1
	if n != 0 and m != 0 and (k != 0):
		ans += 1
	print(ans)


casos = int(input())
respuetas = []
for i in range(casos):
	lista = list(str(input()).split())
	for j in range(len(lista)):
		lista[j] = int(lista[j])
	contador = 0
	if lista[0] > 0:
		contador += 1
		lista[0] -= 1
	if lista[1] > 0:
		contador += 1
		lista[1] -= 1
	if lista[2] > 0:
		contador += 1
		lista[2] -= 1
	maximo = lista[0]
	for j in lista:
		if j > maximo:
			maximo = j
	lista.remove(maximo)
	for j in range(len(lista)):
		if maximo > 0 and lista[j] > 0:
			contador += 1
			maximo -= 1
			lista[j] -= 1
	if lista[0] > 0 and lista[1] > 0:
		contador += 1
		lista[0] -= 1
		lista[1] -= 1
	if lista[0] > 0 and lista[1] > 0 and (maximo > 0):
		contador += 1
		lista[1] -= 1
		maximo -= 1
		lista[0] -= 1
	respuetas.append(contador)
for j in respuetas:
	print(j)


import math
testCases = int(input())
for _ in range(testCases):
	foods = list(map(int, input().split()))
	foods.sort()
	foods = foods[::-1]
	count = 0
	for index in range(len(foods)):
		if foods[index] > 0:
			foods[index] -= 1
			count += 1
	for index1 in range(3):
		for index2 in range(index1 + 1, 3):
			if foods[index1] > 0 and foods[index2] > 0:
				foods[index1] -= 1
				foods[index2] -= 1
				count += 1
	if foods[0] > 0 and foods[1] > 0 and (foods[2] > 0):
		count += 1
	print(count)


for _ in range(int(input())):
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	x = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
	cnt = 0
	for i in x:
		for j in i:
			if lis[j] == 0:
				break
		else:
			for j in i:
				lis[j] -= 1
			cnt += 1
	print(cnt)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split(' '))
	y = [a, b, c]
	y = sorted(y, reverse=True)
	i = 2
	count = 0
	if y[-1] >= 4:
		print(7)
	elif y[-1] >= 3:
		print(6)
	elif y[-1] >= 2:
		if y[-2] > 2 or y[-3] > 2:
			print(5)
		else:
			print(4)
	elif y[-1] >= 1:
		if y[-2] > 1:
			print(4)
		else:
			print(3)
	elif y[-2] > 0:
		if y[-2] > 1:
			print(3)
		else:
			print(2)
	elif y[-3] > 0:
		print(1)
	else:
		print(0)


def red(x):
	return max(0, x - 1)
for _ in range(0, int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	n = 0
	n += (a > 0) + (b > 0) + (c > 0)
	a = red(a)
	b = red(b)
	c = red(c)
	if c > 0 and b > 0:
		n += 1
		c = red(c)
		b = red(b)
	if a > 0 and c > 0:
		n += 1
		a = red(a)
		c = red(c)
	if a > 0 and b > 0:
		n += 1
		a = red(a)
		b = red(b)
	n += a > 0 and b > 0 and (c > 0)
	print(n)


import itertools
t = int(input())
for test in range(t):
	meals = [int(x) for x in input().split()]
	res = 0
	for i in range(3):
		if meals[i] > 0:
			res += 1
			meals[i] -= 1
	new_meals = [i for i in meals if i > 0]
	if len(new_meals) == 2:
		res += 1
	elif len(new_meals) == 3:
		lowest = min(new_meals)
		low_ind = new_meals.index(lowest)
		if lowest >= 2:
			res += 3
		elif new_meals.count(1) == 3:
			res += 1
		else:
			res += 2
	if len([i for i in new_meals if i > 2]) == 3:
		res += 1
	print(res)


for _ in range(int(input())):
	food = sorted(list(map(int, input().split())))
	if food[0] == 0:
		if food[1] == 0:
			if food[2] == 0:
				print(0)
			else:
				print(1)
		elif food[1] > 1:
			print(3)
		else:
			print(2)
	elif food[0] >= 4:
		print(7)
	elif food[0] >= 3:
		print(6)
	elif food[0] >= 2:
		if food[2] >= 3:
			print(5)
		else:
			print(4)
	elif food[1] >= 2:
		print(4)
	else:
		print(3)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	stock = sorted([a, b, c])
	all_meals = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	ans = 0
	for m in all_meals:
		possible = True
		for j in range(3):
			if stock[j] - m[j] < 0:
				possible = False
		if possible:
			for j in range(3):
				stock[j] -= m[j]
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	arr = sorted([int(x) for x in input().split()])
	ans = 0
	if arr[2]:
		ans += 1
		arr[2] -= 1
	if arr[1]:
		ans += 1
		arr[1] -= 1
	if arr[0]:
		ans += 1
		arr[0] -= 1
	arr = sorted(arr)
	if arr[1] and arr[2]:
		arr[1] -= 1
		arr[2] -= 1
		ans += 1
	if arr[0] and arr[1]:
		arr[0] -= 1
		arr[1] -= 1
		ans += 1
	if arr[0] and arr[2]:
		arr[0] -= 1
		arr[2] -= 1
		ans += 1
	if arr[0] and arr[1] and arr[2]:
		ans += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	total = 0
	if a:
		a -= 1
		total += 1
	if b:
		b -= 1
		total += 1
	if c:
		c -= 1
		total += 1
	(a, b, c) = sorted([a, b, c], reverse=True)
	if a and b:
		a -= 1
		b -= 1
		total += 1
	if c and b:
		c -= 1
		b -= 1
		total += 1
	if a and c:
		a -= 1
		c -= 1
		total += 1
	if a and b and c:
		total += 1
	print(total)


t = int(input())
for i in range(t):
	l = input()
	l = l.split()
	a = int(l[0])
	b = int(l[1])
	c = int(l[2])
	l = [a, b, c]
	l = sorted(l)
	ans = 0
	if l == [0, 0, 0]:
		print('0')
	elif l[0] == 0 and l[1] == 0:
		print('1')
	elif l[0] == 0:
		if l[1] >= 2:
			print('3')
		else:
			print('2')
	else:
		ans += 3
		l[0] -= 1
		l[1] -= 1
		l[2] -= 1
		ans += (l[1] > 0) * (l[2] > 0)
		l[2] -= 1
		l[1] -= 1
		ans += (l[0] > 0) * (l[2] > 0)
		l[0] -= 1
		l[2] -= 1
		ans += (l[0] > 0) * (l[1] > 0)
		l[0] -= 1
		l[1] -= 1
		ans += (l[1] > 0) * (l[2] > 0) * (l[0] > 0)
		print(ans)


q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	points = 0
	for i in range(3):
		if l[i] > 0:
			l[i] -= 1
			points += 1
	l.sort()
	if l[2] == 0:
		print(points)
		continue
	if l[0] >= 2:
		l[0] -= 2
		l[1] -= 2
		l[2] -= 2
		points += 3
	elif l[0] == 1 and l[2] > 1:
		l[0] -= 1
		l[1] -= 1
		l[2] -= 2
		points += 2
	elif l[2] >= 1 and l[1] >= 1:
		l[2] -= 1
		l[1] -= 1
		points += 1
	l.sort()
	if l[0] >= 1:
		points += 1
	print(points)


t = int(input())
for i in range(t):
	ans = 0
	(a, b, c) = map(int, input().split())
	maxx = max(a, b, c)
	minn = min(a, b, c)
	midd = a + b + c - minn - maxx
	if maxx >= 1:
		ans = ans + 1
		maxx = maxx - 1
	if midd >= 1:
		ans = ans + 1
		midd = midd - 1
	if minn >= 1:
		ans = ans + 1
		minn = minn - 1
	if maxx >= 1 and midd >= 1:
		ans = ans + 1
		maxx = maxx - 1
		midd = midd - 1
	if midd >= 1 and minn >= 1:
		ans = ans + 1
		midd = midd - 1
		minn = minn - 1
	if minn >= 1 and maxx >= 1:
		ans = ans + 1
		minn = minn - 1
		maxx = maxx - 1
	if min(maxx, midd, minn):
		ans = ans + 1
	print(ans)


from sys import stdin
from collections import Counter
from math import sqrt, factorial, log10, log, floor, ceil
from itertools import permutations, combinations, combinations_with_replacement
input = stdin.readline

def li():
	return list(map(int, input().split()))

def lis():
	return list(map(str, input().split()))

def mp():
	return map(int, input().split())

def inp():
	return int(input())

def inps():
	return str(input().strip())

def pr(n):
	return stdout.write(str(n) + '\n')
INF = float('inf')

def solve():
	a = li()
	res = 0
	for i in range(3):
		if a[i] > 0:
			res += 1
			a[i] -= 1
	a.sort(reverse=True)
	for i in range(2):
		for j in range(i + 1, 3):
			if a[i] > 0 and a[j] > 0:
				a[i] -= 1
				a[j] -= 1
				res += 1
	if 0 not in a:
		res += 1
	print(res)
t = inp()
for i in range(t):
	solve()


t = int(input())
s = []
for i in range(t):
	s.append(list(map(int, input().split())))
for i in range(t):
	visitors = 0
	if s[i][0] > 0:
		s[i][0] -= 1
		visitors += 1
	if s[i][1] > 0:
		s[i][1] -= 1
		visitors += 1
	if s[i][2] > 0:
		s[i][2] -= 1
		visitors += 1
	if s[i][0] > 1:
		if s[i][0] > 0 and s[i][1] > 0:
			s[i][0] -= 1
			s[i][1] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][2] > 0:
			s[i][0] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][1] > 0 and s[i][2] > 0:
			s[i][1] -= 1
			s[i][2] -= 1
			visitors += 1
	elif s[i][1] > 1:
		if s[i][0] > 0 and s[i][1] > 0:
			s[i][0] -= 1
			s[i][1] -= 1
			visitors += 1
		if s[i][1] > 0 and s[i][2] > 0:
			s[i][1] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][2] > 0:
			s[i][0] -= 1
			s[i][2] -= 1
			visitors += 1
	elif s[i][2] > 1:
		if s[i][1] > 0 and s[i][2] > 0:
			s[i][1] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][2] > 0:
			s[i][0] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][1] > 0:
			s[i][0] -= 1
			s[i][1] -= 1
			visitors += 1
	else:
		if s[i][1] > 0 and s[i][2] > 0:
			s[i][1] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][2] > 0:
			s[i][0] -= 1
			s[i][2] -= 1
			visitors += 1
		if s[i][0] > 0 and s[i][1] > 0:
			s[i][0] -= 1
			s[i][1] -= 1
			visitors += 1
	if s[i][0] > 0 and s[i][1] > 0 and (s[i][2] > 0):
		s[i][0] -= 1
		s[i][1] -= 1
		s[i][2] -= 1
		visitors += 1
	print(visitors)


t = int(input())
m = []
for a in [0, 1]:
	for b in [0, 1]:
		for c in [0, 1]:
			m.append([a, b, c])
m.remove([0, 0, 0])
for tt in range(t):
	n = []
	(a, b, c) = sorted(map(int, input().split()))
	for aa in [0, 1]:
		for bb in [0, 1]:
			for cc in [0, 1]:
				if a >= aa and b >= bb and (c >= cc):
					n.append([aa, bb, cc])
					a -= aa
					b -= bb
					c -= cc
	print(len(n) - 1)


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(1500000.0)
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)


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(a, b, c) = read()
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	l = [a, b, c]
	l.sort()
	if l[2] > 0 and l[1] > 0:
		ans += 1
		l[2] -= 1
		l[1] -= 1
	if l[2] > 0 and l[0] > 0:
		ans += 1
		l[2] -= 1
		l[0] -= 1
	if l[0] > 0 and l[1] > 0:
		ans += 1
		l[0] -= 1
		l[1] -= 1
	if l[0] > 0 and l[1] > 0 and (l[2] > 0):
		ans += 1
	print(ans)


def solve(a, b, c):
	cnt = 0
	if a:
		a -= 1
		cnt += 1
	if b:
		b -= 1
		cnt += 1
	if c:
		c -= 1
		cnt += 1
	if a and b and (c >= 2):
		if b and c:
			b -= 1
			c -= 1
			cnt += 1
		if c and a:
			c -= 1
			a -= 1
			cnt += 1
		if a and b:
			a -= 1
			b -= 1
			cnt += 1
	else:
		if a and b:
			a -= 1
			b -= 1
			cnt += 1
		if b and c:
			b -= 1
			c -= 1
			cnt += 1
		if c and a:
			c -= 1
			a -= 1
			cnt += 1
	if a and b and c:
		a -= 1
		b -= 1
		c -= 1
		cnt += 1
	return cnt

def main():
	t = int(input())
	for _ in range(t):
		print(solve(*map(int, input().split())))
main()


from collections import Counter
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	m = min(l)
	M = max(l)
	s = sum(l)
	c = Counter(l)
	if m >= 4:
		ans = 7
	elif m == 3:
		ans = 6
	elif m == 2 and M >= 3:
		ans = 5
	elif m == 1 and c[1] == 1 or (m == 2 and M == 2):
		ans = 4
	elif m == 1 and c[1] >= 2 or (m == 0 and c[0] == 1 and (c[1] == 0)):
		ans = 3
	elif m == 0 and c[1] >= 1 and (c[0] == 1):
		ans = 2
	elif m == 0 and c[0] == 2:
		ans = 1
	elif M == 0:
		ans = 0
	print(ans)


a = int(input())
for i in range(a):
	z = list(map(int, input().split()))
	z.sort()
	total = 0
	if z[0] == 0:
		if z[1] == 0:
			if z[2] == 0:
				print(0)
			else:
				print(1)
			continue
		else:
			if z[1] == 1:
				print(2)
				continue
			if z[1] >= 2:
				print(3)
				continue
	elif z[0] == 1:
		z[0] = z[0] - 1
		z[1] = z[1] - 1
		z[2] = z[2] - 1
		total = total + 3
		if z[1] == 0:
			print(total)
			continue
		elif z[1] >= 1:
			print(total + 1)
			continue
	elif z[0] == 2:
		z[0] = z[0] - 2
		z[1] = z[1] - 1
		z[2] = z[2] - 2
		total = total + 4
		if z[1] >= 1 and z[2] >= 1:
			print(total + 1)
			continue
		else:
			print(total)
			continue
	elif z[0] == 3:
		print(6)
		continue
	else:
		print(7)
		continue


def solve(a, b, c):
	count = 0
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	if c > b:
		(b, c) = (c, b)
	if b > a:
		(a, b) = (b, a)
	if a > 0 and b > 0:
		count += 1
		a -= 1
		b -= 1
	if b > 0 and c > 0:
		count += 1
		c -= 1
		b -= 1
	if c > 0 and a > 0:
		count += 1
		c -= 1
		a -= 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)
t = int(input())
for i in range(0, t):
	inp = list(map(lambda x: int(x), input().split()))
	solve(inp[0], inp[1], inp[2])


S = ([0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1])
n = 0
A = []
n = int(input())
ans = 0
count = 0
x = [0, 0, 0]
for i in range(n):
	A.append([int(j) for j in input().split()])
for t in range(n):
	ans = 0
	for i in range(1 << 7):
		count = 0
		x = [0, 0, 0]
		for j in range(7):
			if 1 << j & i != 0:
				count += 1
				for k in range(3):
					x[k] += S[j][k]
		if x[0] <= A[t][0] and x[1] <= A[t][1] and (x[2] <= A[t][2]) and (ans < count):
			ans = count
	print(ans, end='\n')


for i in range(int(input())):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	b = []
	if a[0] > 0:
		a[0] = a[0] - 1
		b.append(a[0])
	if a[1] > 0:
		a[1] = a[1] - 1
		b.append(a[1])
	if a[2] > 0:
		a[2] = a[2] - 1
		b.append(a[2])
	if a[0] > 0 and a[1] > 0:
		a[0] = a[0] - 1
		a[1] = a[1] - 1
		b.append((a[0], a[1]))
	if a[1] > 0 and a[2] > 0:
		a[1] = a[1] - 1
		a[2] = a[2] - 1
		b.append((a[1], a[2]))
	if a[0] > 0 and a[2] > 0:
		a[0] = a[0] - 1
		a[2] = a[2] - 1
		b.append((a[0], a[2]))
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		a[0] = a[0] - 1
		a[1] = a[1] - 1
		a[2] = a[2] - 1
		b.append((a[0], a[1], a[2]))
	print(len(b))


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


def program():
	l = list(map(int, input().split()))
	sum = 0
	for i in range(3):
		if l[i] >= 1:
			sum += 1
			l[i] -= 1
	l.sort(reverse=True)
	for i in range(3):
		for j in range(i):
			if l[i] >= 1 and l[j] >= 1:
				sum += 1
				l[i] -= 1
				l[j] -= 1
	if l[0] >= 1 and l[1] >= 1 and (l[2] >= 1):
		sum += 1
	print(sum)
t = int(input())
for i in range(t):
	program()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
for _ in range(get_int()):
	(a, b, c) = sorted(get_int_list())
	count = 0
	if a >= 1:
		count += 1
		a -= 1
	if b >= 1:
		count += 1
		b -= 1
	if c >= 1:
		count += 1
		c -= 1
	if b >= 1 and c >= 1:
		count += 1
		b -= 1
		c -= 1
	if a >= 1 and c >= 1:
		count += 1
		a -= 1
		c -= 1
	if a >= 1 and b >= 1:
		count += 1
		a -= 1
		b -= 1
	if a >= 1 and b >= 1 and (c >= 1):
		count += 1
		a -= 1
		b -= 1
		c -= 1
	print(count)


_ = int(input())
for __ in range(_):
	(a, b, c) = sorted(list(map(int, input().split())), reverse=True)
	res = 0
	res += min(1, a) + min(1, b) + min(1, c)
	a -= min(1, a)
	b -= min(1, b)
	c -= min(1, c)
	res += min([1, a, b])
	u = min([1, a, b])
	a -= u
	b -= u
	res += min([1, a, c])
	u = min([1, a, c])
	a -= u
	c -= u
	res += min([1, c, b])
	u = min([1, c, b])
	c -= u
	b -= u
	res += min([1, a, b, c])
	u = min([1, a, b, c])
	a -= u
	b -= u
	c -= u
	print(res)


def REST(L):
	flag = 0
	for i in range(0, 3):
		if L[i] > 0:
			L[i] = L[i] - 1
			flag = flag + 1
	if L[1] > 0 and L[0] > 0:
		L[1] = L[1] - 1
		L[0] = L[0] - 1
		flag = flag + 1
	if L[1] > 0 and L[2] > 0:
		L[1] = L[1] - 1
		L[2] = L[2] - 1
		flag = flag + 1
	if L[2] > 0 and L[0] > 0:
		L[2] = L[2] - 1
		L[0] = L[0] - 1
		flag = flag + 1
	if L[1] > 0 and L[0] > 0 and (L[2] > 0):
		flag = flag + 1
	return flag
a = int(input())
for i in range(0, a):
	flag = 0
	L = list(map(int, input().split()))
	L.sort(reverse=True)
	res = REST(L)
	print(res)


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	(c, b, a) = sorted([int(x) for x in input().split()])
	res = 0
	if a:
		a -= 1
		res += 1
	if b:
		b -= 1
		res += 1
	if c:
		c -= 1
		res += 1
	if a and b:
		a -= 1
		b -= 1
		res += 1
	if a and c:
		a -= 1
		c -= 1
		res += 1
	if c and b:
		c -= 1
		b -= 1
		res += 1
	if a and b and c:
		res += 1
	print(res)
tt = int(input())
for test in range(tt):
	solve()


for _ in range(int(input())):
	vals = [*map(int, input().split())]
	t = 0
	for i in range(len(vals)):
		if vals[i] > 0:
			vals[i] -= 1
			t += 1
	for pairs in sorted([(1, 2), (0, 1), (0, 2)], key=lambda x: max(vals[x[0]], vals[x[1]]), reverse=True):
		(a, b) = pairs
		if vals[a] > 0 and vals[b] > 0:
			t += 1
			vals[a] -= 1
			vals[b] -= 1
	if vals[0] > 0 and vals[1] > 0 and (vals[2] > 0):
		t += 1
	print(t)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	s = 0
	if a > 0:
		a -= 1
		s += 1
	if b > 0:
		b -= 1
		s += 1
	if c > 0:
		c -= 1
		s += 1
	l = [a, b, c]
	if a == max(l):
		if a > 0 and b > 0:
			s += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			s += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			s += 1
			c -= 1
			b -= 1
	elif b == max(l):
		if a > 0 and b > 0:
			s += 1
			a -= 1
			b -= 1
		if c > 0 and b > 0:
			s += 1
			c -= 1
			b -= 1
		if a > 0 and c > 0:
			s += 1
			a -= 1
			c -= 1
	else:
		if a > 0 and c > 0:
			s += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			s += 1
			c -= 1
			b -= 1
		if a > 0 and b > 0:
			s += 1
			a -= 1
			b -= 1
	if a > 0 and b > 0 and (c > 0):
		s += 1
	print(s)
	t -= 1


def solve():
	(a, b, c) = sorted(map(int, input().split()), reverse=True)
	ans = 0
	if a >= 1:
		ans += 1
		a -= 1
	if b >= 1:
		ans += 1
		b -= 1
	if c >= 1:
		ans += 1
		c -= 1
	if a >= 1 and b >= 1:
		ans += 1
		a -= 1
		b -= 1
	if c >= 1 and a >= 1:
		ans += 1
		c -= 1
		a -= 1
	if b >= 1 and c >= 1:
		ans += 1
		c -= 1
		b -= 1
	if b >= 1 and c >= 1 and (a >= 1):
		ans += 1
	return ans
t = int(input())
for _ in range(t):
	print(solve())


n = int(input())
for _ in range(n):
	l = list(map(int, input().split()))
	l.sort()
	total = -1
	for i in range(2):
		for j in range(2):
			for k in range(2):
				if i <= l[0] and j <= l[1] and (k <= l[2]):
					total += 1
					l[0] -= i
					l[1] -= j
					l[2] -= k
	print(total)


T = int(input())
reslst = []
for i in range(T):
	m = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	v = 0
	l = list(map(int, input().split()))
	l.sort()
	for j in m:
		if l[0] - j[0] >= 0 and l[1] - j[1] >= 0 and (l[2] - j[2] >= 0):
			v = v + 1
			l[0] = l[0] - j[0]
			l[1] = l[1] - j[1]
			l[2] = l[2] - j[2]
	reslst.append(v)
print(*reslst, sep='\n')


from sys import stdin
from math import ceil
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(a, b, c) = sorted(map(int, input().split()))
	ans = 0
	if a > 0:
		ans += 1
	if b > 0:
		ans += 1
	if c > 0:
		ans += 1
	if min(a, b, c) > 3:
		ans += 1
	if b > 1 and c > 1:
		ans += 1
		b -= 1
		c -= 1
	if a > 1 and c > 1:
		ans += 1
		a -= 1
	if a > 1 and b > 1:
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	summ = 0
	if a != 0:
		summ += 1
		a -= 1
	if b != 0:
		summ += 1
		b -= 1
	if c != 0:
		summ += 1
		c -= 1
	D = [a, b, c]
	D = sorted(D, reverse=True)
	a = D[0]
	b = D[1]
	c = D[2]
	if a != 0 and b != 0:
		summ += 1
		a -= 1
		b -= 1
	if b != 0 and c != 0:
		summ += 1
		b -= 1
		c -= 1
	if a != 0 and c != 0:
		summ += 1
		a -= 1
		c -= 1
	if (a != 0 and b != 0) and c != 0:
		summ += 1
	print(summ)


for i in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	count = 0
	if l.count(0) == 1:
		l[2] -= 1
		l[1] -= 1
		count += 2
		if l[1] > 0 and l[2] > 0:
			count += 1
		print(count)
		continue
	if l.count(0) == 2:
		print(1)
		continue
	if max(l) == 1:
		print(l.count(1))
		continue
	if max(l) == 0:
		print(0)
		continue
	if min(l) >= 4:
		print(7)
		continue
	if l[0] > 0:
		l[0] -= 1
		l[1] -= 1
		l[2] -= 1
		count += 3
	if l[0] > 0 and l[1] > 1:
		l[0] -= 1
		l[1] -= 1
		count += 1
	l.sort()
	if l[1] > 0:
		if l[0] == 0:
			count += 0
		else:
			l[0] -= 1
			l[2] -= 1
			count += 1
	l.sort()
	if l.count(0) == 1:
		count += 1
	print(count)


q = int(input())
for _ in range(q):
	s = [int(i) for i in input().split()]
	s.sort()
	(a1, b1, c1) = (s[0], s[1], s[2])
	ans = 0
	for a in [0, 1]:
		for b in [0, 1]:
			for c in [0, 1]:
				if a == 0 and b == 0 and (c == 0) or a > a1 or b > b1 or (c > c1):
					continue
				ans += 1
				a1 -= a
				b1 -= b
				c1 -= c
	print(ans)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = 0
	l = []
	if a >= 1:
		a -= 1
		s += 1
		if a != 0:
			l.append(a)
	if b >= 1:
		b -= 1
		s += 1
		if b != 0:
			l.append(b)
	if c >= 1:
		c -= 1
		s += 1
		if c != 0:
			l.append(c)
	ll = len(l)
	if ll == 0 or ll == 1:
		print(s)
	if ll == 2:
		print(s + 1)
	else:
		l.sort()
		try:
			if l[-1] == 0 or l[-2] == 0:
				print(s)
			else:
				s += 1
				l[-1] -= 1
				l[-2] -= 1
				if l[-1] == 0 or l[0] == 0:
					print(s)
				else:
					l[-1] -= 1
					l[0] -= 1
					s += 1
					if l[-2] == 0 or l[0] == 0:
						print(s)
					else:
						l[-2] -= 1
						l[0] -= 1
						s += 1
						if l[0] == 0 or l[1] == 0 or l[2] == 0:
							print(s)
						else:
							print(s + 1)
		except:
			pass


import os
import heapq
import sys
import math
import operator
from collections import defaultdict, deque
from bisect import bisect_right, bisect_left
from io import BytesIO, IOBase
from copy import copy

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(a, b, c) = inpt()
		if a >= 4 and b >= 4 and (c >= 4):
			print(7)
		else:
			ar = [a, b, c]
			ar.sort(reverse=True)
			ans = 0
			for i in range(3):
				if ar[i] > 0:
					ar[i] -= 1
					ans += 1
			if ar[0] > 0 and ar[1] > 0:
				ans += 1
				ar[0] -= 1
				ar[1] -= 1
			if ar[0] > 0 and ar[2] > 0:
				ans += 1
				ar[0] -= 1
				ar[2] -= 1
			if ar[1] > 0 and ar[2] > 0:
				ans += 1
				ar[1] -= 1
				ar[2] -= 1
			print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


def f():
	A = [int(s) for s in input().split()]
	A.sort()
	(a, b, c) = A
	if c == 0:
		return 0
	if c == 1:
		return a + b + c
	if b <= 1:
		return a + b + 1
	if a <= 1:
		return a + 3
	if a >= 4:
		return 7
	if a == 3:
		return 6
	if c >= 3:
		return 5
	else:
		return 4
T = int(input())
for t in range(T):
	print(f())


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	brr = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	arr = [a, b, c]
	arr.sort()
	ans = 0
	for i in brr:
		flag = 0
		for j in range(3):
			if i[j] == 1 and arr[j] == 0:
				flag = 1
		if flag == 0:
			ans += 1
			for j in range(3):
				if i[j] == 1:
					arr[j] -= 1
	print(ans)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	a = lInt()
	ans = 0
	for i in range(3):
		if a[i] > 0:
			ans += 1
			a[i] -= 1
	a.sort()
	if a[2] > 0 and a[1] > 0:
		ans += 1
		a[2] -= 1
		a[1] -= 1
	if a[0] > 0 and a[2] > 0:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0:
		ans += 1
		a[0] -= 1
		a[1] -= 1
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		ans += 1
	print(ans)


n = int(input())
while n:
	l1 = sorted([min(4, int(x)) for x in input().split()])
	l2 = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	l2.sort()
	i = 0
	while (l1[0] > 0 or l1[1] > 0 or l1[2] > 0) and len(l2):
		for x in l2:
			if l1[0] >= x[0] and l1[1] >= x[1] and (l1[2] >= x[2]):
				l1[0] -= x[0]
				l1[1] -= x[1]
				l1[2] -= x[2]
				i += 1
				l2[l2.index(x)] = [5, 5, 5]
			else:
				l2.remove(x)
	print(i)
	n -= 1


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


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter
from itertools import combinations as comb
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	arr = l()
	arr = sorted(arr)
	(a, b, c) = (arr[2], arr[1], arr[0])
	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 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		c -= 1
		a -= 1
	if b > 0 and c > 0:
		ans += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	out(str(ans) + '\n')


t = int(input())
for k in range(t):
	l = [int(x) for x in input().split()]
	L = []
	l.sort()
	v = 0
	if l[0] > 0:
		l[0] -= 1
		v += 1
	if l[1] > 0:
		l[1] -= 1
		v += 1
	if l[2] > 0:
		l[2] -= 1
		v += 1
	if l[1] > 0:
		v += 1
		l[1] -= 1
		l[2] -= 1
	if l[0] > 0 and l[2] > 0:
		v += 1
		l[0] -= 1
		l[2] -= 1
	if l[0] > 0 and l[2] > 0:
		v += 1
		l[0] -= 1
		l[1] -= 1
		l[2] -= 1
	if l[0] > 0 and l[1] > 0:
		v += 1
		l[1] -= 1
		l[0] -= 1
	print(v)


for test_case in range(int(input())):
	nums = list(map(int, input().split()))
	ans = 0
	if nums[0] > 0:
		ans += 1
		nums[0] -= 1
	if nums[1] > 0:
		ans += 1
		nums[1] -= 1
	if nums[2] > 0:
		ans += 1
		nums[2] -= 1
	nums.sort(reverse=True)
	if nums[0] > 0 and nums[2] > 0:
		ans += 1
		nums[0] -= 1
		nums[2] -= 1
	if nums[0] > 0 and nums[1] > 0:
		ans += 1
		nums[0] -= 1
		nums[1] -= 1
	if nums[1] > 0 and nums[2] > 0:
		ans += 1
		nums[1] -= 1
		nums[2] -= 1
	if nums[0] > 0 and nums[1] > 0 and (nums[2] > 0):
		ans += 1
	print(ans)


from sys import stdin
rd = stdin.readline
for _ in range(int(rd())):
	a = list(map(int, rd().split()))
	ans = 0
	a.sort()
	if a[2] > 0:
		ans += 1
		a[2] -= 1
	if a[1] > 0:
		ans += 1
		a[1] -= 1
	if a[0] > 0:
		ans += 1
		a[0] -= 1
	if a[2] and a[1]:
		ans += 1
		a[2] -= 1
		a[1] -= 1
	if a[0] and a[2]:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] and a[1]:
		ans += 1
		a[0] -= 1
		a[1] -= 1
	if a[0] and a[1] and a[2]:
		ans += 1
	print(ans)


import sys
import math

def scan(input_type='int'):
	if input_type == 'int':
		return list(map(int, sys.stdin.readline().strip().split()))
	else:
		return list(map(str, sys.stdin.readline().strip()))

def solution():
	for _ in range(int(input())):
		e = scan()
		e.sort()
		e.reverse()
		(a, b, c) = e
		d = 0
		if a > 0:
			d += 1
			a -= 1
		if b > 0:
			b -= 1
			d += 1
		if c > 0:
			d += 1
			c -= 1
		if a > 0 and b > 0:
			a -= 1
			b -= 1
			d += 1
		if a > 0 and c > 0:
			a -= 1
			c -= 1
			d += 1
		if b > 0 and c > 0:
			b -= 1
			c -= 1
			d += 1
		if a > 0 and b > 0 and (c > 0):
			d += 1
		print(d)
solution()


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

	def a1(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 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
		return ans

	def a2(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 1
		if a > 0 and c > 0:
			ans += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			ans += 1
			b -= 1
			c -= 1
		if a > 0 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		return ans

	def a3(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 1
		if c > 0 and b > 0:
			ans += 1
			c -= 1
			b -= 1
		if b > 0 and a > 0:
			ans += 1
			b -= 1
			a -= 1
		if a > 0 and c > 0:
			ans += 1
			a -= 1
			c -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		return ans

	def a4(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 1
		if c > 0 and b > 0:
			ans += 1
			c -= 1
			b -= 1
		if a > 0 and c > 0:
			ans += 1
			c -= 1
			a -= 1
		if a > 0 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		return ans

	def a5(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 1
		if a > 0 and c > 0:
			ans += 1
			c -= 1
			a -= 1
		if b > 0 and a > 0:
			ans += 1
			b -= 1
			a -= 1
		if b > 0 and c > 0:
			ans += 1
			b -= 1
			c -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		return ans

	def a6(a, b, c):
		ans = 0
		if a > 0:
			a -= 1
			ans += 1
		if b > 0:
			b -= 1
			ans += 1
		if c > 0:
			c -= 1
			ans += 1
		if a > 0 and b > 0:
			ans += 1
			a -= 1
			b -= 1
		if c > 0 and a > 0:
			ans += 1
			c -= 1
			a -= 1
		if b > 0 and c > 0:
			ans += 1
			b -= 1
			c -= 1
		if a > 0 and b > 0 and (c > 0):
			ans += 1
		return ans
	print(max(a1(a, b, c), a2(a, b, c), a3(a, b, c), a4(a, b, c), a5(a, b, c), a6(a, b, c)))


for t in range(int(input())):
	arr = list(map(int, input().split()))
	arr.sort()
	(i, j, k) = (arr[2], arr[1], arr[0])
	(a, b, c) = (0, 0, 0)
	(ab, bc, ac) = (0, 0, 0)
	abc = 0
	if i > 0:
		a = 1
		i -= 1
	if j > 0:
		b = 1
		j -= 1
	if k > 0:
		c = 1
		k -= 1
	if i > 0 and j > 0:
		ab = 1
		i -= 1
		j -= 1
	if i > 0 and k > 0:
		ac = 1
		i -= 1
		k -= 1
	if k > 0 and j > 0:
		bc = 1
		k -= 1
		j -= 1
	if i > 0 and k > 0 and (j > 0):
		abc = 1
	print(a + b + c + ab + bc + ac + abc)


for i in range(int(input())):
	lst = [int(i) for i in input().split()]
	lst.sort(reverse=True)
	if lst[0] > 3 and lst[1] > 3 and (lst[2] > 3):
		print(7)
	else:
		quantity = 0
		for j in range(3):
			if lst[j] > 0:
				quantity += 1
				lst[j] -= 1
		if lst[0] != 0 and lst[1] != 0:
			quantity += 1
			(lst[0], lst[1]) = (lst[0] - 1, lst[1] - 1)
		if lst[0] != 0 and lst[2] != 0:
			quantity += 1
			(lst[0], lst[2]) = (lst[0] - 1, lst[2] - 1)
		if lst[1] != 0 and lst[2] != 0:
			quantity += 1
			(lst[2], lst[1]) = (lst[2] - 1, lst[1] - 1)
		if lst[0] != 0 and lst[1] != 0 and (lst[2] != 0):
			quantity += 1
		print(quantity)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	if a[0] >= 3 and a[1] >= 3 and (a[2] >= 3):
		if a[0] > 3 and a[1] > 3 and (a[2] > 3):
			print(7)
		else:
			print(6)
		continue
	count = 0
	for i in range(3):
		if a[i] > 0:
			count += 1
			a[i] -= 1
	j = -1
	zero_count = 0
	one_count = 0
	for i in range(3):
		if a[i] == 0:
			zero_count += 1
		if a[i] == 1:
			one_count += 1
	if zero_count >= 1:
		if zero_count == 1:
			count += 1
	elif one_count >= 1:
		if one_count <= 2:
			count += 2
		else:
			count += 1
	print(count)


number_of_testcases = int(input())
for i in range(number_of_testcases):
	A = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]
	abclist = list(map(int, input().split(' ')))
	abclist.sort(reverse=True)
	(a, b, c) = abclist
	dishes = 0
	for j in A:
		flag = 1
		if j[0] <= a and j[1] <= b and (j[2] <= c):
			dishes = dishes + 1
			a = a - j[0]
			b = b - j[1]
			c = c - j[2]
	print(dishes)


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)


import sys
import bisect
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 30
MOD = 998244353
for _ in range(int(ri())):
	(a, b, c) = Ri()
	cnt = 0
	if a > 0:
		a -= 1
		cnt += 1
	if b > 0:
		b -= 1
		cnt += 1
	if c > 0:
		c -= 1
		cnt += 1
	temp = max(a, b, c)
	if a == temp:
		if a > 0 and b > 0:
			cnt += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			cnt += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			cnt += 1
			c -= 1
			b -= 1
	if b == temp:
		if a > 0 and b > 0:
			cnt += 1
			a -= 1
			b -= 1
		if b > 0 and c > 0:
			cnt += 1
			c -= 1
			b -= 1
		if a > 0 and c > 0:
			cnt += 1
			c -= 1
			a -= 1
	if c == temp:
		if a > 0 and c > 0:
			cnt += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			cnt += 1
			c -= 1
			b -= 1
		if b > 0 and a > 0:
			cnt += 1
			a -= 1
			b -= 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
	print(cnt)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	a.sort()
	ans = 0
	if a[0] >= 1:
		ans += 1
		a[0] -= 1
	if a[1] >= 1:
		ans += 1
		a[1] -= 1
	if a[2] >= 1:
		ans += 1
		a[2] -= 1
	if a[1] >= 1 and a[2] >= 1:
		ans += 1
		a[2] -= 1
		a[1] -= 1
	if a[0] >= 1 and a[2] >= 1:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] >= 1 and a[1] >= 1:
		ans += 1
		a[0] -= 1
		a[1] -= 1
	if a[0] >= 1 and a[2] >= 1 and (a[1] >= 1):
		ans += 1
		a[0] -= 1
		a[2] -= 1
		a[1] -= 1
	print(ans)


t = int(input())
for tt in range(t):
	abc = [int(x) for x in input().split(' ')]
	q = 0
	for i in range(3):
		if abc[i]:
			q += 1
			abc[i] -= 1
	abc.sort()
	if abc[-1] and abc[-2]:
		q += 1
		abc[-1] -= 1
		abc[-2] -= 1
	if abc[-1] and abc[0]:
		abc[-1] -= 1
		abc[0] -= 1
		q += 1
	if abc[0] and abc[1]:
		q += 1
		abc[0] -= 1
		abc[1] -= 1
	if abc[-1] and abc[-2] and abc[-3]:
		q += 1
	print(q)


t = int(input())
for o in range(t):
	(a, b, c) = list(map(int, input().split()))
	arr = [a, b, c]
	tmp = [a, b, c]
	counter = 0
	if arr[0] > 0:
		arr[0] -= 1
		counter += 1
	if arr[1] > 0:
		arr[1] -= 1
		counter += 1
	if arr[2] > 0:
		arr[2] -= 1
		counter += 1
	if arr.index(max(arr)) < 2:
		if (arr[0] > 0) & (arr[1] > 0):
			arr[0] -= 1
			arr[1] -= 1
			counter += 1
		if (arr[1] > 0) & (arr[2] > 0):
			arr[1] -= 1
			arr[2] -= 1
			counter += 1
	else:
		if (arr[1] > 0) & (arr[2] > 0):
			arr[1] -= 1
			arr[2] -= 1
			counter += 1
		if (arr[0] > 0) & (arr[1] > 0):
			arr[0] -= 1
			arr[1] -= 1
			counter += 1
	if (arr[0] > 0) & (arr[2] > 0):
		arr[0] -= 1
		arr[2] -= 1
		counter += 1
	if (arr[0] > 0) & (arr[1] > 0) & (arr[2] > 0):
		arr[0] -= 1
		arr[1] -= 1
		arr[2] -= 1
		counter += 1
	print(counter)


def solve(a, b, c):
	slist = [a, b, c]
	slist.sort()
	(a, b, c) = slist
	mlist = [(0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
	cnt = 0
	for (da, db, dc) in mlist:
		if a >= da and b >= db and (c >= dc):
			a -= da
			b -= db
			c -= dc
			cnt += 1
	return cnt
T = int(input())
for t in range(T):
	(a, b, c) = tuple(map(int, input().split()))
	print(solve(a, b, c))


T = int(input())
answer = ''
for t in range(T):
	l = list(map(int, input().split()))
	l.sort()
	(c, b, a) = l
	result = 0
	if a != 0:
		result += 1
		a -= 1
	if b != 0:
		result += 1
		b -= 1
	if c != 0:
		result += 1
		c -= 1
	if a != 0 and b != 0:
		a -= 1
		b -= 1
		result += 1
	if a != 0 and c != 0:
		a -= 1
		c -= 1
		result += 1
	if b != 0 and c != 0:
		b -= 1
		c -= 1
		result += 1
	if a != 0 and b != 0 and (c != 0):
		result += 1
	answer += str(result) + '\n'
print(answer)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	r = 0
	if a >= 1:
		a -= 1
		r += 1
	if b >= 1:
		b -= 1
		r += 1
	if c >= 1:
		c -= 1
		r += 1
	(a, b, c) = sorted([a, b, c], reverse=True)
	if a >= 1 and b >= 1:
		a -= 1
		b -= 1
		r += 1
	if a >= 1 and c >= 1:
		a -= 1
		c -= 1
		r += 1
	if b >= 1 and c >= 1:
		b -= 1
		c -= 1
		r += 1
	if a >= 1 and b >= 1 and (c >= 1):
		a -= 1
		b -= 1
		c -= 1
		r += 1
	print(r)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import math
mod = 10 ** 9
mod += 7

def main():
	for i in range(ii()):
		(a, b, c) = mi()
		ans = 0
		l = [a, b, c]
		l.sort(reverse=True)
		if l == [1, 1, 0]:
			ans = 2
		elif min(l) >= 4:
			ans = 7
		elif l[1] == l[2] == 1:
			ans = 3
		elif l[0] >= 4 and l[1] >= 2 and (l[2] == 0):
			ans = 3
		elif l[0] >= 3 and l[1] >= 3 and (l[2] >= 3):
			ans = 6
		elif l[0] >= 3 and l[1] >= 2 and (l[2] >= 2):
			ans = 5
		elif l[0] >= 3 and l[1] >= 2 and (l[2] == 1):
			ans = 4
		elif l[0] >= 3 and l[1] >= 2 and (l[2] == 0):
			ans = 3
		elif l[0] >= 3 and l[1] >= 1:
			ans = 2
		elif l == [2, 2, 1] or l == [2, 2, 2]:
			ans = 4
		elif l == [2, 2, 0]:
			ans = 3
		elif l[0] >= 2 and l[2] >= 1:
			ans = 3
		elif l[0] >= 2 and l[1] >= 1:
			ans = 2
		elif l[0] >= 1 and l[1] == 0:
			ans = 1
		elif min(l) == 1:
			ans = 3
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


p = ([1], [2], [3], [1, 2], [1, 2, 3])
for _ in range(int(input())):
	l = list(map(int, input().split(' ')))
	a = 0
	for i in p:
		if len(i) == 1:
			i = i[0]
			if l[i - 1] > 0:
				a += 1
				l[i - 1] -= 1
		elif len(i) == 2:
			ind = l.index(max(l))
			if ind == 0:
				p1 = [[1, 2], [1, 3], [2, 3]]
			elif ind == 1:
				p1 = [[2, 1], [2, 3], [1, 3]]
			else:
				p1 = [[3, 1], [3, 2], [1, 2]]
			for q in p1:
				t = 0
				for j in q:
					if l[j - 1] <= 0:
						t = 1
						break
				if t == 0:
					a += 1
					for j in q:
						l[j - 1] -= 1
		else:
			t = 0
			for j in i:
				if l[j - 1] <= 0:
					t = 1
					break
			if t == 0:
				a += 1
				for j in i:
					l[j - 1] -= 1
	print(a)


for case in range(int(input())):
	temp = [int(x) for x in input().split()]
	temp.sort(reverse=True)
	(a, b, c) = temp
	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 * b > 0:
		ans += 1
		a -= 1
		b -= 1
	if b * c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a * c > 0:
		ans += 1
		a -= 1
		c -= 1
	if a * b * c > 0:
		ans += 1
	print(ans)


r = ''
for t in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())), reverse=True)
	suma = 0
	if a > 0:
		a -= 1
		suma += 1
	if b > 0:
		b -= 1
		suma += 1
	if c > 0:
		c -= 1
		suma += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		suma += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		suma += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		suma += 1
	if a > 0 and b > 0 and (c > 0):
		suma += 1
	r += f'{suma}\n'
print(r)


t = int(input())
for i in range(t):
	(a, b, c) = input().strip().split(' ')
	(a, b, c) = [int(a), int(b), int(c)]
	p = 0
	if a:
		a -= 1
		p += 1
	if b:
		b -= 1
		p += 1
	if c:
		c -= 1
		p += 1
	x = [a, b, c]
	x.sort()
	a = x[2]
	b = x[1]
	c = x[0]
	if a and c:
		a -= 1
		c -= 1
		p += 1
	if a and b:
		a -= 1
		b -= 1
		p += 1
	if b and c:
		b -= 1
		c -= 1
		p += 1
	if a and b and c:
		a -= 1
		b -= 1
		c -= 1
		p += 1
	print(p)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
import bisect as bi
import heapq

def I():
	return int(input())

def In():
	return map(int, input().split())

def check(l):
	d = 0
	for i in range(3):
		if l[i] >= 1:
			d += 1
	if d >= 1:
		return 1
	else:
		return 0

def main():
	try:
		(a, b, c) = In()
		if a >= 4 and b >= 4 and (c >= 4):
			print(7)
		elif a == 0 and b == 0 and (c == 0):
			print(0)
		else:
			l = [a, b, c]
			l.sort()
			ans = 0
			for i in range(3):
				if l[i] >= 1:
					l[i] -= 1
					ans += 1
			if sum(l) > 0:
				l.sort()
				if l[2] >= 1 and l[1] >= 1:
					l[2] -= 1
					l[1] -= 1
					ans += 1
				if l[2] >= 1 and l[0] >= 1:
					l[0] -= 1
					l[2] -= 1
					ans += 1
				if l[0] >= 1 and l[1] >= 1:
					l[1] -= 1
					l[0] -= 1
					ans += 1
				if l[0] >= 1 and l[1] >= 1 and (l[2] >= 1):
					ans += 1
			print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


def try_to_feed(counts, portion):
	new_counts = [counts[i] - portion[i] for i in range(len(counts))]
	if all((x >= 0 for x in new_counts)):
		for i in range(len(counts)):
			counts[i] = new_counts[i]
		return 1
	else:
		return 0
t = int(input())
for i in range(t):
	counts = map(int, input().split())
	counts = list(reversed(sorted(counts)))
	guests_feeded = 0
	guests_feeded += try_to_feed(counts, [1, 0, 0])
	guests_feeded += try_to_feed(counts, [0, 1, 0])
	guests_feeded += try_to_feed(counts, [0, 0, 1])
	guests_feeded += try_to_feed(counts, [1, 1, 0])
	guests_feeded += try_to_feed(counts, [1, 0, 1])
	guests_feeded += try_to_feed(counts, [0, 1, 1])
	guests_feeded += try_to_feed(counts, [1, 1, 1])
	print(guests_feeded)


t = int(input())
ans = []
for x in range(t):
	m = sorted(list(map(int, input().split())))
	cus = 0
	(a, b, c) = m[::-1]
	if a >= 1:
		cus += 1
		a -= 1
	if b >= 1:
		cus += 1
		b -= 1
	if c >= 1:
		cus += 1
		c -= 1
	if a >= 1 and b >= 1:
		cus += 1
		a -= 1
		b -= 1
	if a >= 1 and c >= 1:
		cus += 1
		a -= 1
		c -= 1
	if b >= 1 and c >= 1:
		cus += 1
		b -= 1
		c -= 1
	if a >= 1 and b >= 1 and (c >= 1):
		cus += 1
	ans.append(cus)
for y in ans:
	print(y)


from itertools import permutations

def zeros(l):
	zeros_num = 0
	for x in l:
		zeros_num += int(x == 0)
	if l[0] == 0:
		zeros_num += 0.3
	if l[1] == 0:
		zeros_num += 0.15
	if l[2] == 0:
		zeros_num += 0.05
	return zeros_num
t = int(input())
for t1 in range(t):
	score = 0
	(a, b, c) = input().split()
	state = [int(a), int(b), int(c)]
	state.sort()
	state = tuple(state)
	c = list(set(permutations([0, 0, 1, 1, 1], 3)))
	c.sort(key=lambda x: zeros(x), reverse=True)
	for perm in c:
		temp_res = tuple(map(lambda i, j: i - j, state, perm))
		if -1 not in temp_res:
			state = temp_res
			score += 1
	print(score)


from itertools import permutations

def solution():
	t = int(input())
	for _ in range(t):
		p = list(map(int, input().split(' ')))
		print(serve(p, set()))

def serve(prepared, servedSet):
	if sum(prepared) == 0:
		return 0
	mx = -1
	results = [0]
	for i in range(1, 4):
		perm_serve = [0] * (3 - i)
		perm_serve += [1] * i
		for s in set(permutations(perm_serve)):
			if s not in servedSet:
				(dump, cran, panc) = s
				if prepared[0] < dump or prepared[1] < cran or prepared[2] < panc:
					continue
				servedSet.add(s)
				prepared[0] -= dump
				prepared[1] -= cran
				prepared[2] -= panc
				n = serve(prepared, servedSet)
				results.append(1 + n)
				prepared[0] += dump
				prepared[1] += cran
				prepared[2] += panc
	return max(results)
solution()


T = int(input())
for t in range(1, T + 1):
	answer = 0
	d = list((int(x) for x in input().split()))
	if d[0] >= 4 and d[1] >= 4 and (d[2] >= 4):
		print('7')
		continue
	elif d[0] >= 3 and d[1] >= 3 and (d[2] >= 3):
		print('6')
		continue
	elif d[0] >= 2 and d[1] >= 2 and (d[2] >= 3) or (d[1] >= 2 and d[2] >= 2 and (d[0] >= 3)) or (d[0] >= 2 and d[2] >= 2 and (d[1] >= 3)):
		print('5')
		continue
	else:
		for i in range(len(d)):
			if d[i] >= 1:
				d[i] -= 1
				answer += 1
		if d[0] >= 1 and d[1] >= 1 and (d[2] >= 0) or (d[0] >= 1 and d[1] >= 0 and (d[2] >= 1)) or (d[0] >= 0 and d[1] >= 1 and (d[2] >= 1)):
			answer += 1
		print(answer)


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


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


from sys import stdin

def inp():
	return next((ss.rstrip() for ss in stdin))

def itg():
	return int(inp())

def mpint():
	return map(int, inp().split())
from copy import deepcopy
K1 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
K2 = [[1, 1, 0], [0, 1, 1], [1, 0, 1]]
K3 = [[1, 1, 1]]

def f(kk):
	global a, b, c, ans
	while kk:
		p = max(kk, key=lambda k: k[0] * a + k[1] * b + k[2] * c)
		if (not p[0] or a) and (not p[1] or b) and (not p[2] or c):
			ans += 1
			if p[0]:
				a -= 1
			if p[1]:
				b -= 1
			if p[2]:
				c -= 1
		kk.remove(p)
for i in range(itg()):
	(a, b, c) = mpint()
	ans = 0
	k1 = deepcopy(K1)
	k2 = deepcopy(K2)
	k3 = deepcopy(K3)
	f(k1)
	f(k2)
	f(k3)
	print(ans)


n = int(input())
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	(a, b, c) = sorted([a, b, c])[::-1]
	flags = [False, False, False, False, False, False, False]
	if a != 0:
		a -= 1
		flags[0] = True
	if b != 0:
		b -= 1
		flags[1] = True
	if c != 0:
		c -= 1
		flags[2] = True
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		flags[3] = True
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		flags[4] = True
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		flags[5] = True
	if a > 0 and b > 0 and (c > 0):
		flags[6] = True
	print(sum(flags))


n = int(input())
for i in range(n):
	ara = list(map(int, input().split()))
	ara.sort(reverse=True)
	a = ara[0]
	b = ara[1]
	c = ara[2]
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	if a > 0 and b > 0:
		count += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		count += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		count += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
		a -= 1
		b -= 1
		c -= 1
	print(count)


def f(ll, a, b, c, pos):
	if pos == len(ll):
		return 0
	excl = f(ll, a, b, c, pos + 1)
	flag = True
	mask = ll[pos]
	if mask & 1 > 0:
		if a > 0:
			a -= 1
		else:
			flag = False
	if mask & 2 > 0:
		if b > 0:
			b -= 1
		else:
			flag = False
	if mask & 4 > 0:
		if c > 0:
			c -= 1
		else:
			flag = False
	incl = 0
	if flag:
		incl = 1 + f(ll, a, b, c, pos + 1)
	return max(excl, incl)
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ll = [1, 2, 4, 6, 5, 3, 7]
	print(f(ll, a, b, c, 0))


n = int(input())

def havePortion(a):
	if a - 1 >= 0:
		return True
	return False
for x in range(n):
	(a, b, c) = [int(i) for i in input().split()]
	if a > b:
		(a, b) = (b, a)
	elif c > b:
		(c, b) = (b, c)
	total = 0
	if havePortion(a):
		a -= 1
		total += 1
	if havePortion(b):
		b -= 1
		total += 1
	if havePortion(c):
		c -= 1
		total += 1
	if havePortion(a) and havePortion(b):
		a -= 1
		b -= 1
		total += 1
	if havePortion(a) and havePortion(c):
		a -= 1
		c -= 1
		total += 1
	if havePortion(b) and havePortion(c):
		b -= 1
		c -= 1
		total += 1
	if havePortion(a) and havePortion(b) and havePortion(c):
		a -= 1
		b -= 1
		c -= 1
		total += 1
	print(total)


from itertools import combinations

def is_duplicates(d):
	a = 0
	b = 0
	c = 0
	for i in d:
		if i == 'a':
			a += 1
		if i == 'b':
			b += 1
		if i == 'c':
			c += 1
		if a >= 2 or b >= 2 or c >= 2:
			return True
	return False

def process():
	(a, b, c) = sorted(list(map(int, input().split())), reverse=True)
	res = 0
	if a >= 1:
		a -= 1
		res += 1
	if b >= 1:
		b -= 1
		res += 1
	if c >= 1:
		c -= 1
		res += 1
	if a >= 1 and b >= 1:
		a -= 1
		b -= 1
		res += 1
	if a >= 1 and c >= 1:
		a -= 1
		c -= 1
		res += 1
	if b >= 1 and c >= 1:
		b -= 1
		c -= 1
		res += 1
	if a >= 1 and b >= 1 and (c >= 1):
		res += 1
	print(res)
tests = int(input())
for i in range(0, tests):
	process()


n = int(input())
for i in range(n):
	x = input()
	l = x.split()
	for i in range(len(l)):
		l[i] = int(l[i])
	l.sort(reverse=True)
	s = 0
	for i in range(len(l)):
		if l[i] != 0:
			s += 1
			l[i] -= 1
	if l[0] != 0 and l[1] != 0:
		s += 1
		l[0] -= 1
		l[1] -= 1
	if l[0] != 0 and l[2] != 0:
		s += 1
		l[0] -= 1
		l[2] -= 1
	if l[1] != 0 and l[2] != 0:
		s += 1
		l[1] -= 1
		l[2] -= 1
	if l[0] != 0 and l[1] != 0 and (l[2] != 0):
		s += 1
	print(s)
	s = 0


for _ in range(int(input())):
	li = list(map(int, input().split()))
	co = 0
	li.sort(reverse=True)
	if li[0]:
		co += 1
		li[0] -= 1
	if li[1]:
		co += 1
		li[1] -= 1
	if li[2]:
		co += 1
		li[2] -= 1
	if li[0] and li[2]:
		co += 1
		li[0] -= 1
		li[2] -= 1
	if li[1] and li[2]:
		co += 1
		li[1] -= 1
		li[2] -= 1
	if li[0] and li[1]:
		co += 1
		li[0] -= 1
		li[1] -= 1
	if li[0] and li[1] and li[2]:
		co += 1
	print(co)


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


for _ in range(int(input())):
	num = list(map(int, input().split()))
	ans = 0
	num.sort(reverse=True)
	if num[0] != 0:
		ans += 1
		num[0] -= 1
	if num[1] != 0:
		ans += 1
		num[1] -= 1
	if num[2] != 0:
		ans += 1
		num[2] -= 1
	if num[0] > 0 and num[1] > 0:
		ans += 1
		num[0] -= 1
		num[1] -= 1
	if num[1] > 0 and num[2] > 0:
		ans += 1
		num[1] -= 1
		num[2] -= 1
	if num[0] > 0 and num[2] > 0:
		ans += 1
		num[0] -= 1
		num[2] -= 1
	if num[0] > 0 and num[1] > 0 and (num[2] > 0):
		ans += 1
	print(ans)


def sol():
	T = int(input())
	for i in range(T):
		(a, b, c) = map(int, input().split(' '))
		portion_list = [a, b, c]
		count = 0
		for i in range(3):
			if portion_list[i] > 0:
				count += 1
				portion_list[i] -= 1
		portion_list.sort(reverse=True)
		if portion_list[0] > 0 and portion_list[1] > 0:
			count += 1
			portion_list[0] -= 1
			portion_list[1] -= 1
		if portion_list[0] > 0 and portion_list[2] > 0:
			count += 1
			portion_list[0] -= 1
			portion_list[2] -= 1
		if portion_list[1] > 0 and portion_list[2] > 0:
			count += 1
			portion_list[1] -= 1
			portion_list[2] -= 1
		if portion_list[0] > 0 and portion_list[1] > 0 and (portion_list[2] > 0):
			count += 1
		print(count)
sol()


n = int(input())
for i in range(n):
	t = 0
	s = input().split()
	for j in range(3):
		s[j] = int(s[j])
	s.sort(reverse=True)
	if s[0] == 0:
		t = 0
	else:
		for j in range(3):
			if s[j] > 0:
				t += 1
				s[j] -= 1
		if s[0] > 0 and s[1] > 0:
			s[0] -= 1
			s[1] -= 1
			t += 1
		if s[0] > 0 and s[2] > 0:
			s[0] -= 1
			s[2] -= 1
			t += 1
		if s[1] > 0 and s[2] > 0:
			s[2] -= 1
			s[1] -= 1
			t += 1
		if s[0] > 0 and s[1] > 0 and (s[2] > 0):
			t += 1
	print(t)


t = int(input())
if t <= 0 or t > 500:
	exit(0)
temp = int(t)
list1 = []
test = []
work = []
while t > 0:
	t = t - 1
	inputstring = input()
	inputlist = inputstring.split()
	test.append(int(inputlist[0]))
	test.append(int(inputlist[1]))
	test.append(int(inputlist[2]))
i = 0
while i < 3 * temp:
	result = 0
	test[i:i + 3] = sorted(test[i:i + 3])
	if test[i + 2] != 0:
		test[i + 2] -= 1
		result += 1
	if test[i + 1] != 0:
		test[i + 1] -= 1
		result += 1
	if test[i] != 0:
		test[i] -= 1
		result += 1
	if test[i + 2] != 0 and test[i + 1] != 0:
		test[i + 2] -= 1
		test[i + 1] -= 1
		result += 1
	if test[i] != 0 and test[i + 2] != 0:
		test[i + 2] -= 1
		test[i] -= 1
		result += 1
	if test[i] != 0 and test[i + 1] != 0:
		test[i] -= 1
		test[i + 1] -= 1
		result += 1
	if test[i + 2] != 0 and test[i] != 0 and (test[i + 1] != 0):
		result += 1
	list1.append(result)
	i += 3
j = 0
while j < temp:
	print(int(list1[j]))
	j += 1


def calc(dumplings: int, cranberry: int, pancakes: int):
	ans: int = 0
	if 4 <= dumplings and 4 <= cranberry and (4 <= pancakes):
		return 7
	else:
		if dumplings != 0:
			dumplings -= 1
			ans += 1
		if cranberry != 0:
			cranberry -= 1
			ans += 1
		if pancakes != 0:
			pancakes -= 1
			ans += 1
	Dumplings_Cranberry: bool = True
	Dumplings_Pancakes: bool = True
	Cranberry_Pancakes: bool = True
	for _ in range(3):
		if max(cranberry, pancakes) <= dumplings != 0:
			if cranberry != 0 and Dumplings_Cranberry:
				dumplings -= 1
				cranberry -= 1
				ans += 1
				Dumplings_Cranberry = False
			if pancakes != 0 and dumplings != 0 and Dumplings_Pancakes:
				dumplings -= 1
				pancakes -= 1
				ans += 1
				Dumplings_Pancakes = False
		elif max(dumplings, pancakes) <= cranberry != 0:
			if dumplings != 0 and Dumplings_Cranberry:
				dumplings -= 1
				cranberry -= 1
				ans += 1
				Dumplings_Cranberry = False
			if pancakes != 0 and cranberry != 0 and Cranberry_Pancakes:
				cranberry -= 1
				pancakes -= 1
				ans += 1
				Cranberry_Pancakes = False
		elif max(dumplings, cranberry) <= pancakes != 0:
			if dumplings != 0 and Dumplings_Pancakes:
				dumplings -= 1
				pancakes -= 1
				ans += 1
				Dumplings_Pancakes = False
			if cranberry != 0 and pancakes != 0 and Cranberry_Pancakes:
				cranberry -= 1
				pancakes -= 1
				ans += 1
				Cranberry_Pancakes = False
	if dumplings != 0 and cranberry != 0 and (pancakes != 0):
		ans += 1
	return ans

def main():
	for _ in range(int(input())):
		(x, y, z) = map(int, input().split())
		print(calc(x, y, z))
main()


t = int(input())
for hatt in range(t):
	lis = input().split()
	(a, b, cin) = (int(lis[0]), int(lis[1]), int(lis[2]))
	c = [0 for i in range(5)]
	if a == 0:
		c[0] += 1
	elif a == 1:
		c[1] += 1
	elif a == 2:
		c[2] += 1
	elif a == 3:
		c[3] += 1
	else:
		c[4] += 1
	if b == 0:
		c[0] += 1
	elif b == 1:
		c[1] += 1
	elif b == 2:
		c[2] += 1
	elif b == 3:
		c[3] += 1
	else:
		c[4] += 1
	if cin == 0:
		c[0] += 1
	elif cin == 1:
		c[1] += 1
	elif cin == 2:
		c[2] += 1
	elif cin == 3:
		c[3] += 1
	else:
		c[4] += 1
	if c[0] == 3:
		ans = 0
	elif c[0] == 2:
		ans = 1
	elif c[0] == 1:
		if c[1] != 0:
			ans = 2
		else:
			ans = 3
	elif c[1] == 3:
		ans = 3
	elif c[1] == 2:
		ans = 3
	elif c[1] == 1:
		ans = 4
	elif c[2] == 3:
		ans = 4
	elif c[2] == 2:
		ans = 5
	elif c[2] == 1:
		ans = 5
	elif c[4] == 3:
		ans = 7
	else:
		ans = 6
	print(ans)


def bin(n):
	a = str(n % 2)
	r = n // 2
	while r != 0:
		a = str(r % 2) + a
		r //= 2
	if len(a) == 2:
		a = '0' + a
	elif len(a) == 1:
		a = '00' + a
	return a
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if min(a, b, c) >= 4:
		print(7)
	else:
		m = min(a, b, c)
		n = max(a, b, c)
		p = a + b + c - m - n
		(a, b, c) = (m, n, p)
		total = 0
		for i in range(1, 7):
			k = bin(i)
			if a >= int(k[0]) and b >= int(k[1]) and (c >= int(k[2])):
				total += 1
				if int(k[0]) > 0:
					a -= 1
				if int(k[1]) > 0:
					b -= 1
				if int(k[2]) > 0:
					c -= 1
		print(total)


for u in range(int(input())):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	(x, y, z) = (l[0], l[1], l[2])
	c = 0
	if x > 0:
		c += 1
		x -= 1
	if y > 0:
		c += 1
		y -= 1
	if z > 0:
		c += 1
		z -= 1
	if x > 0 and y > 0:
		c += 1
		x -= 1
		y -= 1
	if x > 0 and z > 0:
		c += 1
		x -= 1
		z -= 1
	if y > 0 and z > 0:
		c += 1
		y -= 1
		z -= 1
	if x > 0 and z > 0 and (y > 0):
		c += 1
		x -= 1
		y -= 1
		z -= 1
	print(c)


T = int(input())
while T >= 1:
	pis = 0
	a = list(map(int, input().split()))
	for i in range(len(a)):
		if a[i] >= 9:
			a[i] = 9
	a.sort()
	b = str(a[0]) + str(a[1]) + str(a[2])
	lst = [444, 333, 223, 122, 22, 11, 1, 0]
	check = False
	for i in range(len(lst)):
		if int(b) >= lst[i] and check == False:
			print(7 - i)
			check = True
	T -= 1


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	coun = 0
	l = []
	if a > 0:
		coun += 1
		a -= 1
	if b > 0:
		coun += 1
		b -= 1
	if c > 0:
		coun += 1
		c -= 1
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	if a > 0 and c > 0:
		coun += 1
		a -= 1
		c -= 1
	if c > 0 and b > 0:
		coun += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0:
		coun += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0 and (b > 0):
		coun += 1
	print(coun)


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


t = int(input())
for i in range(t):
	count = 0
	l = list(map(int, input().split()))
	l = sorted(l)
	l.reverse()
	a = l[0]
	b = l[1]
	c = l[2]
	if a > 0:
		a = a - 1
		count += 1
	if b > 0:
		b = b - 1
		count += 1
	if c > 0:
		c = c - 1
		count += 1
	max1 = 0
	a1 = a
	b1 = b
	c1 = c
	for i in range(3):
		a = a1
		b = b1
		c = c1
		count1 = 0
		if a > 0 and b > 0:
			a = a - 1
			b = b - 1
			count1 += 1
		if b > 0 and c > 0:
			b = b - 1
			c = c - 1
			count1 += 1
		if a > 0 and c > 0:
			a = a - 1
			c = c - 1
			count1 += 1
		if count1 > max1:
			max1 = count1
	if a > 0 and b > 0 and (c > 0):
		a = a - 1
		b = b - 1
		c = c - 1
		count += 1
	print(count + max1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	a1 = 0
	b1 = 0
	c1 = 0
	q = 0
	k = 0
	for d in range(2):
		if d == 0:
			k += 1
		else:
			k -= 1
		if d == 0:
			a1 += 1
		else:
			a1 -= 1
		for e in range(2):
			if e == 0:
				k += 1
			else:
				k -= 1
			if e == 0:
				b1 += 1
			else:
				b1 -= 1
			for f in range(2):
				if f == 0:
					k += 1
				else:
					k -= 1
				if f == 0:
					c1 += 1
				else:
					c1 -= 1
				for g in range(2):
					if g == 0:
						k += 1
					else:
						k -= 1
					if g == 0:
						a1 += 1
						b1 += 1
					else:
						a1 -= 1
						b1 -= 1
					for h in range(2):
						if h == 0:
							k += 1
						else:
							k -= 1
						if h == 0:
							b1 += 1
							c1 += 1
						else:
							b1 -= 1
							c1 -= 1
						for i in range(2):
							if i == 0:
								k += 1
							else:
								k -= 1
							if i == 0:
								a1 += 1
								c1 += 1
							else:
								a1 -= 1
								c1 -= 1
							for j in range(2):
								if j == 0:
									k += 1
								else:
									k -= 1
								if j == 0:
									a1 += 1
									b1 += 1
									c1 += 1
								else:
									a1 -= 1
									b1 -= 1
									c1 -= 1
								if k > q and a1 <= a and (b1 <= b) and (c1 <= c):
									q = k
	print(q)


kl = int(input())
for l in range(kl):
	s = [int(i) for i in input().split()]
	s.sort()
	a = min(s[0], 4)
	b = min(s[1], 4)
	c = min(s[2], 4)
	if a == 4:
		print(7)
	elif a == 3:
		print(6)
	elif a == 2:
		if c > 2:
			print(5)
		else:
			print(4)
	elif a == 1:
		if b > 1:
			print(4)
		else:
			print(3)
	elif a == 0:
		if b >= 2:
			print(3)
		elif b == 1:
			print(2)
		elif b == 0:
			if c > 0:
				print(1)
			else:
				print(0)


import itertools
T = int(input())
for _ in range(T):
	(a, b, c) = map(int, input().split())
	ans = 0
	for ptn in itertools.permutations(range(1, 8)):
		x = y = z = 0
		for (i, p) in enumerate(ptn):
			if p & 1:
				x += 1
			if p & 2:
				y += 1
			if p & 4:
				z += 1
			if x > a or y > b or z > c:
				ans = max(ans, i)
				break
		else:
			ans = 7
			break
	print(ans)


from math import *
from collections import *
t = int(input())
for y in range(t):
	l = list(map(int, input().split()))
	l.sort()
	a = l[2]
	b = l[1]
	c = l[0]
	ct = 0
	if a > 0:
		ct += 1
		a -= 1
	if b > 0:
		ct += 1
		b -= 1
	if c > 0:
		ct += 1
		c -= 1
	if a > 0 and b > 0:
		ct += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ct += 1
		a -= 1
		c -= 1
	if c > 0 and b > 0:
		ct += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ct += 1
	print(ct)


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	L.sort()
	a = L[0]
	b = L[1]
	c = L[2]
	nb = 0
	if a >= 4:
		nb = 7
		print(nb)
	else:
		if a == 0:
			if b == 0:
				if c == 0:
					nb = 0
				else:
					nb = 1
			elif b == 1:
				nb = 2
			else:
				nb = 3
		elif a == 1:
			if b == 1:
				nb = 3
			else:
				nb = 4
		elif a == 2:
			if b == 2 and c == 2:
				nb = 4
			else:
				nb = 5
		elif a == 3:
			nb = 6
		print(nb)


n = int(input())
i = 0
while i < n:
	abc = list(map(int, input().split()))
	otv = 0
	ot1 = 0
	abc.sort()
	if abc[0] == 0:
		if abc[1] == 0:
			if abc[2] > 0:
				otv = 1
		elif abc[1] == 1:
			otv = 2
		else:
			otv = 3
	elif abc[0] == 1:
		if abc[1] == 1:
			otv = 3
		else:
			otv = 4
	elif abc[0] == 2:
		if abc[1] == 2:
			if abc[2] == 2:
				otv = 4
			else:
				otv = 5
		else:
			otv = 5
	elif abc[0] == 3:
		otv = 6
	elif abc[0] >= 4:
		otv = 7
	i += 1
	print(otv)


from sys import stdin, stdout
from collections import deque
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def to_bin(n, padding=3):
	ans = deque()
	for _ in range(padding):
		(n, bindig) = divmod(n, 2)
		ans.appendleft(bindig)
	return ans

def main():
	T = int(rl())
	for _ in range(T):
		ans = 0
		A = [int(x) for x in rll()]
		A.sort()
		bits = []
		for i in range(1, 8):
			bits.append(to_bin(i))
		bits.sort(key=lambda b: sum(b))
		for dig in bits:
			if all((A[i] - dig[i] >= 0 for i in range(3))):
				ans += 1
				for i in range(3):
					A[i] -= dig[i]
		stdout.write(str(ans))
		stdout.write('\n')
	stdout.close()
main()


N = int(input())
ans = []
for j in range(N):
	m = list(map(int, input().split()))
	ans.append(0)
	if m[0] > 0:
		m[0] -= 1
		ans[j] += 1
	if m[1] > 0:
		m[1] -= 1
		ans[j] += 1
	if m[2] > 0:
		m[2] -= 1
		ans[j] += 1
	m.sort()
	if m[2] > 0 and m[1] > 0:
		m[2] -= 1
		m[1] -= 1
		ans[j] += 1
	if m[2] > 0 and m[0] > 0:
		m[2] -= 1
		m[0] -= 1
		ans[j] += 1
	if m[1] > 0 and m[0] > 0:
		m[1] -= 1
		m[0] -= 1
		ans[j] += 1
	if m[0] > 0 and m[1] > 0 and (m[2] > 0):
		m[0] -= 1
		m[1] -= 1
		m[2] -= 1
		ans[j] += 1
for j in range(N):
	print(ans[j])


import itertools as it

def func(abc):
	delete1 = [[0], [1], [2]]
	delete2 = [[0, 1], [1, 2], [0, 2]]
	delete3 = [[0, 1, 2]]
	count = 0
	abc = [int(i) for i in abc.split()]
	for i in delete1:
		yes = True
		for j in i:
			if abc[j] == 0:
				yes = False
		if yes == True:
			abc[j] -= 1
			count += 1
	abc.sort(reverse=True)
	for i in delete2:
		yes = True
		for j in i:
			if abc[j] == 0:
				yes = False
		if yes == True:
			abc[j] -= 1
			count += 1
	for i in delete3:
		yes = True
		for j in i:
			if abc[j] == 0:
				yes = False
		if yes == True:
			abc[j] -= 1
			count += 1
	return str(count)

def func2(abc):
	abc = [int(i) for i in abc.split()]
	abc.sort(reverse=True)
	total = 0
	for i in range(3):
		if abc[i] > 0:
			total += 1
			abc[i] -= 1
	if abc[0] > 0 and abc[1] > 0:
		total += 1
		abc[0] -= 1
		abc[1] -= 1
	if abc[0] > 0 and abc[2] > 0:
		total += 1
		abc[0] -= 1
		abc[2] -= 1
	if abc[1] > 0 and abc[2] > 0:
		total += 1
		abc[1] -= 1
		abc[2] -= 1
	if abc[1] > 0 and abc[2] > 0 and (abc[0] > 0):
		total += 1
	return str(total)

def main():
	t = int(input())
	t_input = [input() for i in range(t)]
	print('\n'.join([func2(i) for i in t_input]))
main()


def max_visitors(a, b, c):
	count = 0
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	l = [a, b, c]
	l.sort(reverse=True)
	a = l[0]
	b = l[1]
	c = l[2]
	if a and b:
		count += 1
		a -= 1
		b -= 1
	if a and c:
		count += 1
		a -= 1
		c -= 1
	if b and c:
		count += 1
		b -= 1
		c -= 1
	if a and b and c:
		count += 1
		a -= 1
		b -= 1
		c -= 1
	return count
t = int(input())
for _ in range(t):
	abc = input().split()
	a = int(abc[0])
	b = int(abc[1])
	c = int(abc[2])
	print(max_visitors(a, b, c))


T = int(input())
for z in range(T):
	(a, b, c) = map(int, input().split())
	pw = 0
	if a > 0:
		pw += 1
		a -= 1
	if b > 0:
		pw += 1
		b -= 1
	if c > 0:
		pw += 1
		c -= 1
	(a, b, c) = sorted([a, b, c], reverse=True)
	if a > 0 and b > 0:
		pw += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		pw += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		pw += 1
		b -= 1
		c -= 1
	if a > 0 and c > 0 and (b > 0):
		pw += 1
		a -= 1
		c -= 1
		b -= 1
	print(pw)


for _ in range(int(input())):
	(d, c, p) = map(int, input().split())
	count = 0
	if d > 4:
		d = 4
	if p > 4:
		p = 4
	if c > 4:
		c = 4
	L = [d, c, p]
	L.sort()
	(d, c, p) = L
	if d > 0:
		count += 1
		d -= 1
	if p > 0:
		count += 1
		p -= 1
	if c > 0:
		count += 1
		c -= 1
	if c > 0 and p > 0:
		count += 1
		c -= 1
		p -= 1
	if d > 0 and c > 0:
		count += 1
		c -= 1
		d -= 1
	if d > 0 and p > 0:
		count += 1
		d -= 1
		p -= 1
	if d > 0 and p > 0 and (c > 0):
		count += 1
		d -= 1
		p -= 1
		c -= 1
	print(count)


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


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
t = oint()
for _ in range(t):
	cnt = 0
	a = list(rint())
	for i in range(3):
		if a[i] > 0:
			cnt += 1
			a[i] -= 1
	a.sort(reverse=True)
	if a[0] > 0 and a[1] > 0:
		cnt += 1
		a[0] -= 1
		a[1] -= 1
	if a[1] > 0 and a[2] > 0:
		cnt += 1
		a[1] -= 1
		a[2] -= 1
	if a[0] > 0 and a[2] > 0:
		cnt += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		cnt += 1
	print(cnt)


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)


import sys

def to_binary_digits(i: int, pad: int):
	digits = list(map(int, bin(i)[2:]))
	if len(digits) < pad:
		digits = [0] * (pad - len(digits)) + digits
	return digits
type_count = 3
all_sets = []
for k in range(1, 2 ** type_count):
	all_sets.append(to_binary_digits(k, type_count))
all_options = []
set_size = len(all_sets)
for k in range(1, 2 ** set_size):
	option_min_count = [0] * type_count
	portion_count = 0
	index = to_binary_digits(k, set_size)
	for i in range(set_size):
		if index[i] == 1:
			portion_count += 1
			for j in range(type_count):
				option_min_count[j] += all_sets[i][j]
	all_options.append([portion_count, option_min_count])

def check_option(option, counts):
	init_array = list(counts)
	for i in range(type_count):
		init_array[i] -= option[1][i]
	positive_elem_count = len(list(filter(lambda num: num >= 0, init_array)))
	return positive_elem_count == type_count

def find_max_set_count(counts):
	possible_counts = []
	for opt in iter(all_options):
		if check_option(opt, counts):
			possible_counts.append(opt[0])
	if len(possible_counts) == 0:
		return 0
	return max(possible_counts)
t = int(input())
for i in range(t):
	counts = list(map(int, sys.stdin.readline().split()))
	print(find_max_set_count(counts))


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	t1 = 0
	a.sort()
	p1 = a[0]
	if p1 > 3:
		t1 = 7
	elif p1 == 3:
		t1 = 6
	else:
		if a[0] > 3:
			a[0] = 3
		if a[1] > 3:
			a[1] = 3
		if a[2] > 3:
			a[2] = 3
		if a[0] == 2:
			if a[2] == 2:
				t1 = 4
			elif a[2] == 3:
				t1 = 5
		elif a[0] == 1:
			if a[2] == 3:
				if a[1] == 1:
					t1 = 3
				elif a[1] >= 2:
					t1 = 4
			elif a[2] == 2:
				if a[1] == 1:
					t1 = 3
				elif a[1] >= 2:
					t1 = 4
			else:
				t1 = 3
		elif a[2] == 1:
			if a[1] == 1:
				t1 = 2
			else:
				t1 = 1
		elif a[2] >= 2:
			if a[1] >= 2:
				t1 = 3
			elif a[1] == 1:
				t1 = 2
			else:
				t1 = 1
		else:
			t1 = 0
	print(t1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	if a > 0:
		ans += 1
	if b > 0:
		ans += 1
	if c > 0:
		ans += 1
	l = [a - 1, b - 1, c - 1]
	l.sort()
	if l[2] == 1:
		if l[1] == 1:
			ans += 1
			l[1] -= 1
			l[2] -= 1
	elif l[2] > 1:
		if l[1] >= 1:
			ans += 1
			l[1] -= 1
			l[2] -= 1
		if l[0] >= 1:
			ans += 1
			l[0] -= 1
	if l[1] > 1 and l[0] > 1:
		ans += 1
		l[1] -= 1
		l[0] -= 1
	if min(l) > 0:
		ans += 1
	print(ans)


from itertools import combinations

def calc(A):
	(l, res) = ([], 0)
	A.sort(reverse=True)
	kv = {i: n for (i, n) in enumerate(A) if n > 0}
	for i in range(1, 4):
		comb = list(combinations(kv.keys(), i))
		for c in comb:
			cnt = 0
			for k in c:
				if kv[k] == 0:
					break
				cnt += 1
				kv[k] -= 1
			if cnt == len(c):
				res += 1
	return res
N = int(input())
cases = []
for _ in range(N):
	a = list(map(int, input().split()))
	cases.append(a)
for a in cases:
	print(calc(a))


for _ in range(int(input())):
	L = list(map(int, input().split()))
	L.sort()
	a = L[0]
	b = L[1]
	c = L[2]
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		abc = 0
		ab = 0
		bc = 0
		ac = 0
		counta = 0
		countb = 0
		countc = 0
		if a >= 1:
			counta += 1
			a -= 1
		if b >= 1:
			countb += 1
			b -= 1
		if c >= 1:
			countc += 1
			c -= 1
		if b >= 1 and c >= 1:
			bc += 1
			b -= 1
			c -= 1
		if a >= 1 and c >= 1:
			ac += 1
			a -= 1
			c -= 1
		if a >= 1 and b >= 1:
			ab += 1
			a -= 1
			b -= 1
		if a >= 1 and b >= 1 and (c >= 1):
			abc += 1
			a -= 1
			b -= 1
			c -= 1
		print(counta + countb + countc + ab + bc + ac + abc)


t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split()]
	a.sort()
	if a[0] == 0:
		if a[1] == 0:
			if a[2] == 0:
				print(0)
				continue
			else:
				print(1)
				continue
		elif a[1] == 1:
			print(2)
			continue
		else:
			print(3)
			continue
	elif a[0] == 1:
		if a[1] == 1:
			print(3)
			continue
		else:
			print(4)
			continue
	elif a[0] == 2:
		if a[2] == 2:
			print(4)
			continue
		else:
			print(5)
			continue
	elif a[0] == 3:
		print(6)
		continue
	else:
		print(7)


for u in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	l = [a, b, c]
	l.sort()
	a = l[2]
	b = l[1]
	c = l[0]
	ans += min(1, a) + min(1, b) + min(1, c)
	a -= min(1, a)
	b -= min(1, b)
	c -= min(1, c)
	k1 = min(1, b, a)
	ans += k1
	a -= k1
	b -= k1
	k2 = min(1, a, c)
	ans += k2
	a -= k2
	c -= k2
	k3 = min(1, b, c)
	ans += k3
	b -= k3
	c -= k3
	ans += min(1, a, b, c)
	print(ans)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	l = list(I())
	if min(l) >= 4 and max(l) >= 4:
		print(7)
	elif min(l) >= 3 and max(l) >= 3:
		print(6)
	elif min(l) >= 2 and max(l) >= 3:
		print(5)
	elif l.count(1) <= 1 and l.count(0) == 0 and (max(l) >= 2):
		print(4)
	elif min(l) >= 1:
		print(3)
	else:
		z = l.count(0)
		if z == 3 or z == 2:
			print(3 - z)
		elif l.count(1) == 0:
			print(3)
		else:
			print(2)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a > b:
		foo = b
		b = a
		a = foo
	if a > c:
		foo = c
		c = a
		a = foo
	if b > c:
		foo = c
		c = b
		b = foo
	if a > 3:
		print(7)
	else:
		if a == 3:
			print(6)
		if a == 2:
			if c == 2:
				print(4)
			else:
				print(5)
		if a == 1:
			if b > 1:
				print(4)
			else:
				print(3)
		if a == 0:
			if b > 1:
				print(3)
			elif b == 1:
				print(2)
			elif c == 0:
				print(0)
			else:
				print(1)


i = int(input())
r = []
for _ in range(i):
	(a, b, c) = map(int, input().split())
	k = 0
	if a > 0:
		k += 1
		a -= 1
	if b > 0:
		k += 1
		b -= 1
	if c > 0:
		k += 1
		c -= 1
	d = max(a, b, c)
	j = min(a, b, c)
	b = a + b + c
	a = d
	c = j
	b = b - d - j
	if a > 0 and b > 0:
		k += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		k += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		k += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		k += 1
	r.append(k)
for l in range(i):
	print(r[l])


t = int(input())
inputs = [input() for i in range(t)]

def solve(line):
	ans = 0
	A = list(map(int, line.split()))
	A.sort(reverse=True)
	for i in range(3):
		if A[i] > 0:
			A[i] -= 1
			ans += 1
	for i in range(3):
		if A[i] > 0 and A[(i + 1) % 3] > 0:
			A[i] -= 1
			A[(i + 1) % 3] -= 1
			ans += 1
	if A[0] > 0 and A[1] > 0 and (A[2] > 0):
		ans += 1
	print(ans)
[solve(line) for line in inputs]


T = int(input())
import itertools
from itertools import chain, combinations

def subsets(iterable):
	xs = list(iterable)
	return chain.from_iterable((combinations(xs, n) for n in range(len(xs) + 1)))

def build():
	sets = []
	for a in range(2):
		for b in range(2):
			for c in range(2):
				if (a, b, c) != (0, 0, 0):
					sets.append((a, b, c))
	res = []
	for S in subsets(sets):
		tot = [0, 0, 0]
		for p in S:
			tot[0] += p[0]
			tot[1] += p[1]
			tot[2] += p[2]
		res.append((tuple(tot), len(S)))
	return res
mem = build()

def solve(A, B, C):
	mx = 0
	for (m, l) in mem:
		if m[0] <= A and B >= m[1] and (C >= m[2]):
			mx = max(mx, l)
	return mx
for _ in range(T):
	(A, B, C) = [int(x) for x in input().split()]
	print(solve(A, B, C))


def solution(a_val, b_val, c_val):
	ans = 0
	if a_val:
		ans += 1
		a_val -= 1
	if b_val:
		ans += 1
		b_val -= 1
	if c_val:
		ans += 1
		c_val -= 1
	if a_val and b_val:
		ans += 1
		a_val -= 1
		b_val -= 1
	if a_val and c_val:
		ans += 1
		a_val -= 1
		c_val -= 1
	if b_val and c_val:
		ans += 1
		b_val -= 1
		c_val -= 1
	if a_val and b_val and c_val:
		ans += 1
		a_val -= 1
		b_val -= 1
		c_val -= 1
	return ans
t = input()
for _ in range(int(t)):
	(a_val, b_val, c_val) = sorted([int(x) for x in input().split(' ')], reverse=True)
	print(solution(a_val, b_val, c_val))


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def printARR(arr):
	for e in arr:
		print(e, end=' ')
	print()

def main():
	(a, b, c) = M()
	tmp = [a, b, c]
	(a, b, c) = sorted(tmp)
	ans = 0
	if c > 0:
		ans += 1
		c -= 1
	if b > 0:
		ans += 1
		b -= 1
	if a > 0:
		ans += 1
		a -= 1
	if c * b:
		ans += 1
		c -= 1
		b -= 1
	if a * b:
		ans += 1
		a -= 1
		b -= 1
	if a * c:
		ans += 1
		a -= 1
		c -= 1
	if a * b * c:
		ans += 1
	print(ans)
tc = 1
tc = I()
for _ in range(tc):
	main()


def sub(a, b):
	(a1, a2, a3) = a
	(b1, b2, b3) = b
	return (a1 - b1, a2 - b2, a3 - b3)

def is_less_zero(a):
	(a1, a2, a3) = a
	return a1 < 0 or a2 < 0 or a3 < 0
best_strategy = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
task_number = int(input())
for _ in range(task_number):
	(a, b, c) = map(int, input().split())
	r = tuple(sorted([a, b, c], key=lambda x: -x))
	result = 0
	for st in best_strategy:
		if not is_less_zero(sub(r, st)):
			r = sub(r, st)
			result += 1
	print(result)


e = int(input())
m = []
for i in range(e):
	w = input()
	w = w.split(' ')
	for i in range(3):
		w[i] = int(w[i])
	m.append(w)
for y in m:
	y.sort()
	x = [(1, 0, 0), (0, 0, 1), (0, 1, 0), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
	x.sort()
	(total, i) = (0, 0)
	while len(x) > 0 and i < len(x):
		try:
			if x[i][0] <= y[0] and x[i][1] <= y[1] and (x[i][2] <= y[2]):
				y = [y[0] - x[i][0], y[1] - x[i][1], y[2] - x[i][2]]
				x.pop(i)
				total += 1
			else:
				i += 1
		except Exception as e:
			print('ee', e, 'i', i, len(x))
	print(total)


t = int(input())
for o in range(t):
	a = list(map(int, input().split()))
	a.sort()
	cnt = 0
	if a[0] >= 4:
		a[0] = 0
		a[1] -= 2
		a[2] -= 2
		cnt += 4
	elif a[0] == 3:
		a[1] -= 1
		a[2] -= 1
		cnt += 3
	elif a[0] == 2:
		a[2] -= 1
		cnt += 2
	elif a[0] == 1:
		cnt += 1
	if a[1] >= 2:
		a[2] -= 1
		cnt += 2
	elif a[1] == 1:
		cnt += 1
	if a[2] >= 1:
		cnt += 1
	print(cnt)


import sys
import math
import collections
testcases = int(input())
for _ in range(testcases):
	L = list(map(int, input().split()))
	L.sort()
	a = L[0]
	b = L[1]
	c = L[2]
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		(result1, result4) = (0, 0)
		(result2, result3) = (0, 0)
		(resa, resb) = (0, 0)
		resc = 0
		if a >= 1:
			resa += 1
			a -= 1
		if b >= 1:
			resb += 1
			b -= 1
		if c >= 1:
			resc += 1
			c -= 1
		if b >= 1 and c >= 1:
			result3 += 1
			b -= 1
			c -= 1
		if a >= 1 and c >= 1:
			result4 += 1
			a -= 1
			c -= 1
		if a >= 1 and b >= 1:
			result2 += 1
			a -= 1
			b -= 1
		if a >= 1 and b >= 1 and (c >= 1):
			result1 += 1
			a -= 1
			b -= 1
			c -= 1
		print(resa + resb + resc + result2 + result3 + result4 + result1)


t = int(input())
ans = []
for _ in range(t):
	(a, b, c) = sorted([int(x) for x in input().split()], reverse=True)
	ret = 0
	if a:
		ret = 1
		a -= 1
	if b:
		ret += 1
		b -= 1
	if c:
		ret += 1
		c -= 1
	if a and b:
		ret += 1
		a -= 1
		b -= 1
	if a and c:
		ret += 1
		a -= 1
		c -= 1
	if b and c:
		ret += 1
		b -= 1
		c -= 1
	if a and b and c:
		ret += 1
	ans.append(str(ret))
print('\n'.join(ans))


import itertools
s = [[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]]

def col_sum(v):
	(a, b, c) = (0, 0, 0)
	for (a1, b1, c1) in v:
		a += a1
		b += b1
		c += c1
	return [a, b, c]

def solve(a, b, c):
	global s
	for i in list(range(8))[::-1]:
		for (a1, b1, c1) in map(col_sum, itertools.combinations(s, i)):
			if a1 <= a and b1 <= b and (c1 <= c):
				return i
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(solve(a, b, c))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	sub = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	count = 0
	sor = [a, b, c]
	sor.sort()
	a = sor[0]
	b = sor[1]
	c = sor[2]
	for i in range(len(sub)):
		a1 = a - sub[i][0]
		b1 = b - sub[i][1]
		c1 = c - sub[i][2]
		if a1 >= 0 and b1 >= 0 and (c1 >= 0):
			count += 1
			a = a - sub[i][0]
			b = b - sub[i][1]
			c = c - sub[i][2]
	print(count)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()), reverse=True)
	res = 0
	if a > 0:
		res += 1
		a -= 1
	if b > 0:
		res += 1
		b -= 1
	if c > 0:
		res += 1
		c -= 1
	if a > 0 and b > 0:
		res += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		res += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		res += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		res += 1
	print(res)


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans

def ceil(a, b):
	if a % b == 0:
		return int(a / b)
	else:
		return a // b + 1
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a > 3 and b > 3 and (c > 3):
		print(7)
	else:
		l = [a, b, c]
		l.sort()
		if l[0] == 0:
			if l[1] == 0:
				if l[2] == 0:
					print(0)
				else:
					print(1)
			elif l[1] == 1:
				print(2)
			else:
				print(3)
		else:
			ans = l[0]
			if l[0] == 3:
				print(6)
			elif l[0] == 2:
				if l[1] == 2:
					if l[2] == 2:
						print(4)
					else:
						print(5)
				else:
					print(5)
			elif l[0] == 1:
				if l[1] == 1:
					print(3)
				else:
					print(4)


t = int(input())
for tt in range(t):
	inputX = [int(i) for i in input().split()]
	ans = 0
	for i in range(len(inputX)):
		if inputX[i] > 0:
			ans += 1
			inputX[i] -= 1
	perm = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
	res = 0
	for p in perm:
		xx = list(inputX)
		ress = 0
		for ind in p:
			ind -= 1
			(i, j) = (0, 0)
			if ind == 0:
				(i, j) = (1, 2)
			elif ind == 1:
				(i, j) = (0, 2)
			else:
				(i, j) = (0, 1)
			if min(xx[i], xx[j]) > 0:
				xx[i] -= 1
				xx[j] -= 1
				ress += 1
		if min(xx[0], xx[1], xx[2]) > 0:
			ress += 1
		res = max(res, ress)
	ans += res
	print(ans)


t = int(input())
for _ in range(t):
	s = 0
	lis = list(map(int, input().split()))
	for i in range(3):
		if lis[i] > 0:
			s += 1
			lis[i] -= 1
	lis.sort(reverse=True)
	for i in range(0, 2):
		for j in range(i + 1, 3):
			if lis[i] > 0 and lis[j] > 0:
				s += 1
				lis[i] -= 1
				lis[j] -= 1
	if lis[0] > 0 and lis[1] > 0 and (lis[2] > 0):
		s += 1
	print(s)


T = int(input())
for case in range(1, T + 1):
	(a, b, c) = map(int, input().split())
	visitors = 0
	if a > 0:
		visitors += 1
		a -= 1
	if b > 0:
		visitors += 1
		b -= 1
	if c > 0:
		visitors += 1
		c -= 1
	if a == max(a, b, c):
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
		if b > 0 and c > 0:
			visitors += 1
			b -= 1
			c -= 1
	elif b == max(a, b, c):
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
		if b > 0 and c > 0:
			visitors += 1
			b -= 1
			c -= 1
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
	elif c == max(a, b, c):
		if b > 0 and c > 0:
			visitors += 1
			b -= 1
			c -= 1
		if a > 0 and c > 0:
			visitors += 1
			a -= 1
			c -= 1
		if a > 0 and b > 0:
			visitors += 1
			a -= 1
			b -= 1
	if a > 0 and b > 0 and (c > 0):
		visitors += 1
		a -= 1
		b -= 1
		c -= 1
	print(visitors)


l = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
for _ in range(int(input())):
	d = list(map(int, input().split()))
	c = 0
	d = sorted(d, reverse=True)
	for p in l:
		x = list(map(lambda i: d[i], p))
		if 0 not in x:
			c += 1
			for i in p:
				d[i] = d[i] - 1
	print(c)


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	(a, b, c) = sorted([a, b, c], reverse=True)
	total = 0
	if a >= 1:
		total += 1
		a -= 1
	if b >= 1:
		total += 1
		b -= 1
	if c >= 1:
		total += 1
		c -= 1
	if a > 0 and b > 0:
		total += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		total += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		total += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		total += 1
	print(total)


def rs():
	return input().strip()

def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])
import itertools
from functools import lru_cache

def powerset(iterable, low=0, high=None):
	s = list(iterable)
	if high is None:
		high = len(s) + 1
	return itertools.chain.from_iterable((itertools.combinations(s, r) for r in range(low, high)))

def solve(d):
	ans = 0
	n = len(d)
	indices = list(range(n))
	subsets = list(powerset(indices, 1))
	m = len(subsets)
	for to_take in powerset(subsets):
		a = [0] * n
		ok = True
		for i in range(len(to_take)):
			for j in range(len(to_take[i])):
				a[to_take[i][j]] += 1
				if a[to_take[i][j]] > d[to_take[i][j]]:
					ok = False
					break
		if ok:
			ans = max(ans, len(to_take))
	return ans

def main():
	for _ in range(ri()):
		(a, b, c) = ria()
		print(solve([a, b, c]))
main()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	abc = [a, b, c]
	abc.sort()
	orders = list()
	if 'c' not in orders and c != 0:
		orders.append('c')
		abc[abc.index(c)] -= 1
	if 'b' not in orders and b != 0:
		orders.append('b')
		abc[abc.index(b)] -= 1
	if 'a' not in orders and a != 0:
		orders.append('a')
		abc[abc.index(a)] -= 1
	if str(abc[2]) + str(abc[1]) not in orders and abc[2] != 0 and (abc[1] != 0):
		orders.append(str(abc[2]) + str(abc[1]))
		abc[2] -= 1
		abc[1] -= 1
	if str(abc[1]) + str(abc[0]) not in orders and abc[1] != 0 and (abc[0] != 0):
		orders.append(str(abc[1]) + str(abc[0]))
		abc[1] -= 1
		abc[0] -= 1
	if str(abc[2]) + str(abc[0]) not in orders and abc[2] != 0 and (abc[0] != 0):
		orders.append(str(abc[2]) + str(abc[0]))
		abc[2] -= 1
		abc[0] -= 1
	if str(abc[2]) + str(abc[1]) + str(abc[0]) not in orders and abc[2] != 0 and (abc[1] != 0) and (abc[0] != 0):
		orders.append(str(abc[2]) + str(abc[0]))
		abc[2] -= 1
		abc[1] -= 1
		abc[0] -= 1
	print(len(orders))


q = int(input())
comb = '100010001110101011111'
while q:
	(a, b, c) = map(int, input().split())
	max1 = max(a, b, c)
	min1 = min(a, b, c)
	mid1 = a + b + c - max1 - min1
	ans = 0
	for i in range(0, 19, 3):
		if max1 - int(comb[i]) >= 0 and mid1 - int(comb[i + 1]) >= 0 and (min1 - int(comb[i + 2]) >= 0):
			ans += 1
			max1 -= int(comb[i])
			mid1 -= int(comb[i + 1])
			min1 -= int(comb[i + 2])
	print(ans)
	q -= 1


for _ in range(int(input())):
	(x, y, z) = sorted(map(int, input().split()))
	s = 0
	for i in range(1, 8):
		f = i // 4
		g = (i >> 1) % 2
		if x >= f and y >= g and (z >= i % 2):
			x -= f
			y -= g
			z -= i % 2
			s += 1
	print(s)


from itertools import combinations
n_sets = int(input())
for _ in range(n_sets):
	a = sorted(list(map(int, input().split())), reverse=True)
	n = 0
	if a[0] >= 1:
		a[0] -= 1
		n += 1
	if a[1] >= 1:
		a[1] -= 1
		n += 1
	if a[2] >= 1:
		a[2] -= 1
		n += 1
	a.sort(reverse=True)
	if a[0] >= 1 and a[1] >= 1:
		n += 1
		a[0] -= 1
		a[1] -= 1
	if a[0] >= 1 and a[2] >= 1:
		n += 1
		a[0] -= 1
		a[2] -= 1
	if a[1] >= 1 and a[2] >= 1:
		n += 1
		a[1] -= 1
		a[2] -= 1
	if a[0] >= 1 and a[1] >= 1 and (a[2] >= 1):
		n += 1
	print(n)


for _ in range(int(input())):
	ls = [int(x) for x in input().split()]
	ls.sort()
	ls = ls[::-1]
	a = ls[0]
	b = ls[1]
	c = ls[2]
	ans = 0
	if a != 0:
		a -= 1
		ans += 1
	if b != 0:
		b -= 1
		ans += 1
	if c != 0:
		c -= 1
		ans += 1
	if a != 0 and b != 0:
		a -= 1
		b -= 1
		ans += 1
	if b != 0 and c != 0:
		b -= 1
		c -= 1
		ans += 1
	if a != 0 and c != 0:
		a -= 1
		c -= 1
		ans += 1
	if a != 0 and b != 0 and (c != 0):
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	z = 0
	(a, b, c) = map(int, input().split())
	(a, b, c) = (max(a, b, c), a + b + c - max(a, b, c) - min(a, b, c), min(a, b, c))
	if a >= 1:
		a -= 1
		z += 1
	if b >= 1:
		b -= 1
		z += 1
	if c >= 1:
		c -= 1
		z += 1
	if a >= 1 and b >= 1:
		a -= 1
		b -= 1
		z += 1
	if a >= 1 and c >= 1:
		a -= 1
		c -= 1
		z += 1
	if c >= 1 and b >= 1:
		c -= 1
		b -= 1
		z += 1
	if a >= 1 and b >= 1 and (c >= 1):
		c -= 1
		a -= 1
		b -= 1
		z += 1
	print(z)


from functools import lru_cache

@lru_cache(maxsize=None)
def solve(a, b, c):
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 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:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	return ans
t = int(input())
for case_num in range(t):
	items = list(map(int, input().split(' ')))
	items.sort()
	(a, b, c) = items
	print(solve(a, b, c))


def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = [int(x) for x in input().split()]
		visitors = 0
		taken = {}
		if a >= 1:
			visitors += 1
			a -= 1
			taken['a'] = 1
		if b >= 1:
			visitors += 1
			b -= 1
			taken['b'] = 1
		if c >= 1:
			visitors += 1
			c -= 1
			taken['c'] = 1
		l = sorted([a, b, c], reverse=True)
		if l[0] > 0 and l[1] > 0:
			l[0] -= 1
			l[1] -= 1
			visitors += 1
		if l[0] > 0 and l[2] > 0:
			l[0] -= 1
			l[2] -= 1
			visitors += 1
		if l[1] > 0 and l[2] > 0:
			l[1] -= 1
			l[2] -= 1
			visitors += 1
		if l[0] > 0 and l[1] > 0 and (l[2] > 0):
			visitors += 1
		print(visitors)
main()


import itertools
t = int(input())
for _ in range(t):
	A = list(map(int, input().split()))
	ans = 0
	for (a, b, c) in itertools.permutations(A):
		cur = 0
		for i in range(1, 8):
			(d, e, f) = map(int, str(bin(i))[2:].zfill(3))
			if a >= d and b >= e and (c >= f):
				cur += 1
				a -= d
				b -= e
				c -= f
		ans = max(ans, cur)
	print(ans)


t = int(input())
l = []
for a in range(t):
	count = 0
	(a, b, c) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	most = max(a, b, c)
	if a == most and a > 0:
		if b > 0:
			a -= 1
			b -= 1
			count += 1
		if c > 0 and a > 0:
			a -= 1
			c -= 1
			count += 1
		if c > 0 and b > 0:
			c -= 1
			b -= 1
			count += 1
	elif b == most and b > 0:
		if a > 0:
			a -= 1
			b -= 1
			count += 1
		if b > 0 and c > 0:
			b -= 1
			c -= 1
			count += 1
		if a > 0 and c > 0:
			a -= 1
			c -= 1
			count += 1
	elif c == most and c > 0:
		if b > 0:
			c -= 1
			b -= 1
			count += 1
		if c > 0 and a > 0:
			a -= 1
			c -= 1
			count += 1
		if a > 0 and b > 0:
			a -= 1
			b -= 1
			count += 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	l.append(count)
for a in l:
	print(a)


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


time = int(input())
for _ in range(time):
	z = sorted(list(map(int, input().split())))
	k = 0
	if z[2] > 0:
		z[2] -= 1
		k += 1
	if z[1] > 0:
		z[1] -= 1
		k += 1
	if z[0] > 0:
		z[0] -= 1
		k += 1
	if z[2] > 0 and z[1] > 0:
		z[2] -= 1
		z[1] -= 1
		k += 1
	if z[2] > 0 and z[0] > 0:
		z[2] -= 1
		z[0] -= 1
		k += 1
	if z[1] > 0 and z[0] > 0:
		z[1] -= 1
		z[0] -= 1
		k += 1
	if z[2] > 0 and z[1] > 0 and (z[0] > 0):
		k += 1
	print(k)


def main():
	t = int(input())
	for __ in range(t):
		count = 0
		a = list(map(int, input().split()))
		a.sort()
		if a[0] > 0:
			count += 1
			a[0] -= 1
		if a[1] > 0:
			count += 1
			a[1] -= 1
		if a[2] > 0:
			count += 1
			a[2] -= 1
		if a[2] > 0 and a[1] > 0:
			count += 1
			a[2] -= 1
			a[1] -= 1
		if a[1] > 0 and a[0] > 0:
			count += 1
			a[0] -= 1
			a[1] -= 1
		if a[2] > 0 and a[0] > 0:
			count += 1
			a[2] -= 1
			a[0] -= 1
		if a[0] > 0 and a[1] > 0 and (a[2] > 0):
			count += 1
		print(count)
main()


from sys import stdin
T = int(stdin.readline().strip())
for caso in range(T):
	(a, b, c) = map(int, stdin.readline().strip().split())
	s = [a, b, c]
	ans = 0
	for i in range(3):
		if s[i] != 0:
			s[i] -= 1
			ans += 1
	s.sort(reverse=True)
	for i in range(3):
		for j in range(i + 1, 3):
			if s[i] > 0 and s[j] > 0:
				ans += 1
				s[i] -= 1
				s[j] -= 1
	if s.count(0) == 0:
		ans += 1
	print(ans)


def xdlamo(s, L):
	stonc = list(s)
	fed = 0
	for x in L:
		if stonc[0] - x[0] >= 0 and stonc[1] - x[1] >= 0 and (stonc[2] - x[2] >= 0):
			for y in range(len(x)):
				stonc[y] -= x[y]
			fed += 1
	return fed
for i in range(int(input())):
	stock = [int(x) for x in input().split()]
	brute = [[[0, 1, 1], [1, 0, 1], [1, 1, 0]], [[0, 1, 1], [1, 1, 0], [1, 0, 1]], [[1, 0, 1], [1, 1, 0], [0, 1, 1]], [[1, 1, 0], [1, 0, 1], [0, 1, 1]], [[1, 0, 1], [0, 1, 1], [1, 1, 0]], [[1, 1, 0], [0, 1, 1], [1, 0, 1]]]
	brute2 = [[[1, 0, 0], [0, 1, 0], [0, 0, 1], x[0], x[1], x[2], [1, 1, 1]] for x in brute]
	ans = max([xdlamo(stock, x) for x in brute2])
	print(ans)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	count = 0
	if l[0] != 0:
		count += 1
		l[0] -= 1
	if l[1] != 0:
		count += 1
		l[1] -= 1
	if l[2] != 0:
		count += 1
		l[2] -= 1
	if l[0] != 0 and l[1] != 0:
		count += 1
		l[0] -= 1
		l[1] -= 1
	if l[0] != 0 and l[2] != 0:
		l[0] -= 1
		l[2] -= 1
		count += 1
	if l[1] != 0 and l[2] != 0:
		l[1] -= 1
		l[2] -= 1
		count += 1
	if l[1] != 0 and l[2] != 0 and (l[0] != 0):
		count += 1
	print(count)


def get_dishes(a, b, c, count, larr, i):
	if a < 0 or b < 0 or c < 0:
		return count - 1
	if i == 8:
		return count
	count_1 = get_dishes(a, b, c, count, larr, i + 1)
	count_2 = get_dishes(a - larr[i][0], b - larr[i][1], c - larr[i][2], count + 1, larr, i + 1)
	return max(count_1, count_2)
t = int(input())
larr = []
for i in [0, 1]:
	for j in [0, 1]:
		for k in [0, 1]:
			larr.append([i, j, k])
for _ in range(t):
	(a, b, c) = map(int, input().split())
	print(get_dishes(a, b, c, 0, larr, 1))


def main():
	(a, b, c) = map(int, input().split())
	if a >= 4 and b >= 4 and (c >= 4):
		return 7
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	(a, b, c) = sorted([a, b, c])[::-1]
	if a > 0 and b > 0:
		(a, b) = (a - 1, b - 1)
		ans += 1
	if a > 0 and c > 0:
		(a, c) = (a - 1, c - 1)
		ans += 1
	if b > 0 and c > 0:
		(b, c) = (b - 1, c - 1)
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		return ans + 1
	return ans
for _ in range(int(input())):
	print(main())


for _ in range(int(input())):
	l = [int(x) for x in input().split()]
	l.sort()
	if l[0] >= 4:
		print(7)
	elif l[0] == 3:
		print(6)
	elif l[0] == 2:
		if l[1] >= 2 and l[2] >= 3:
			print(5)
		else:
			print(4)
	elif l[0] == 1:
		if l[1] >= 2:
			print(4)
		else:
			print(3)
	elif l[2] == 0:
		print(0)
	elif l[1] >= 2:
		print(3)
	elif l[1] == 1:
		print(2)
	else:
		print(1)


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


t = int(input())
for i in range(t):
	count = 0
	(a, b, c) = map(int, input().split())
	arr = [a, b, c]
	arr = sorted(arr, reverse=True)
	(a, b, c) = (arr[0], arr[1], arr[2])
	for j in range(7):
		if j == 0:
			if a != 0:
				a -= 1
				count += 1
		if j == 1:
			if b != 0:
				b -= 1
				count += 1
		if j == 2:
			if c != 0:
				c -= 1
				count += 1
		if j == 3:
			if a != 0 and b != 0:
				a -= 1
				b -= 1
				count += 1
		if j == 4:
			if a != 0 and c != 0:
				a -= 1
				c -= 1
				count += 1
		if j == 5:
			if b != 0 and c != 0:
				b -= 1
				c -= 1
				count += 1
		if j == 6:
			if a != 0 and b != 0 and (c != 0):
				a -= 1
				b -= 1
				c -= 1
				count += 1
	print(count)


t = int(input())
while t > 0:
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	cu = 0
	if a > 0:
		cu += 1
		a -= 1
	if b > 0:
		cu += 1
		b -= 1
	if c > 0:
		cu += 1
		c -= 1
	if a == 0:
		if b == 0:
			pass
		elif c == 0:
			pass
		else:
			b -= 1
			c -= 1
			cu += 1
	elif a == 1:
		if b == 0:
			if c == 0:
				pass
			else:
				a -= 1
				c -= 1
				cu += 1
		elif b == 1:
			if c == 0 or c == 1:
				a -= 1
				b -= 1
				cu += 1
			else:
				a -= 1
				b -= 1
				c -= 2
				cu += 2
		elif c == 0:
			a -= 1
			b -= 1
			cu += 1
		elif c == 1:
			a -= 1
			b -= 2
			c -= 1
			cu += 2
		else:
			a -= 1
			b -= 1
			c -= 2
			cu += 2
	elif b == 0:
		if c == 0:
			pass
		else:
			a -= 1
			c -= 1
			cu += 1
	elif b == 1:
		if c == 0:
			a -= 1
			b -= 1
			cu += 1
		else:
			a -= 2
			b -= 1
			c -= 1
			cu += 2
	elif c == 0:
		a -= 1
		b -= 1
		cu += 1
	elif c == 1:
		a -= 2
		b -= 1
		c -= 1
		cu += 2
	else:
		a -= 2
		b -= 2
		c -= 2
		cu += 3
	if a > 0 and b > 0 and (c > 0):
		cu += 1
	print(cu)
	t -= 1


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	m = 0
	abc = [a, b, c]
	abc = sorted(abc, reverse=True)
	m = 0
	for i in range(3):
		if abc[i] >= 1:
			abc[i] -= 1
			m += 1
	if abc[0] >= 1 and abc[1] >= 1:
		abc[0] -= 1
		abc[1] -= 1
		m += 1
	if abc[0] >= 1 and abc[2] >= 1:
		abc[0] -= 1
		abc[2] -= 1
		m += 1
	if abc[1] >= 1 and abc[2] >= 1:
		abc[1] -= 1
		abc[2] -= 1
		m += 1
	if abc[0] >= 1 and abc[1] >= 1 and (abc[2] >= 1):
		m += 1
	print(m)


from itertools import product
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	(ta, tb, tc) = (a, b, c)
	data = list(product([0, 1], repeat=3))
	data.sort(key=lambda x: x[0])
	ans1 = 0
	for (x, y, z) in data:
		if a >= x and b >= y and (c >= z):
			a -= x
			b -= y
			c -= z
			ans1 += 1
	(a, b, c) = (ta, tb, tc)
	data.sort(key=lambda x: x[1])
	ans2 = 0
	for (x, y, z) in data:
		if a >= x and b >= y and (c >= z):
			a -= x
			b -= y
			c -= z
			ans2 += 1
	(a, b, c) = (ta, tb, tc)
	data.sort(key=lambda x: x[2])
	ans3 = 0
	for (x, y, z) in data:
		if a >= x and b >= y and (c >= z):
			a -= x
			b -= y
			c -= z
			ans3 += 1
	print(max(ans1, ans2, ans3) - 1)


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	val = 0
	if a >= 1:
		val += 1
		a -= 1
	if b >= 1:
		val += 1
		b -= 1
	if c >= 1:
		val += 1
		c -= 1
	(a, b, c) = (min(a, b, c), a + b + c - min(a, b, c) - max(a, b, c), max(a, b, c))
	if c >= 1 and b >= 1:
		val += 1
		c -= 1
		b -= 1
	if a >= 1 and b >= 1:
		val += 1
		a -= 1
		b -= 1
	if a >= 1 and c >= 1:
		val += 1
		a -= 1
		c -= 1
	if a >= 1 and b >= 1 and (c >= 1):
		val += 1
	print(val)


def sort(a, b, c):
	return (max(a, b, c), a + b + c - max(a, b, c) - min(a, b, c), min(a, b, c))
t = int(input())
result = [0] * t
for i in range(t):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	m = 0
	if a > 0:
		m += 1
		a -= 1
	if b > 0:
		m += 1
		b -= 1
	if c > 0:
		m += 1
		c -= 1
	(a, b, c) = sort(a, b, c)
	if a > 0 and b > 0:
		m += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		m += 1
		a -= 1
		c -= 1
	if c > 0 and b > 0:
		m += 1
		c -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		m += 1
	result[i] = m
for i in range(t):
	print(result[i])


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split(' '))
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	l1 = [a, b, c]
	l1.sort(reverse=True)
	if l1[0] > 0 and l1[1] > 0:
		count += 1
		l1[0] -= 1
		l1[1] -= 1
	if l1[0] > 0 and l1[2] > 0:
		count += 1
		l1[0] -= 1
		l1[2] -= 1
	if l1[1] > 0 and l1[2] > 0:
		count += 1
		l1[1] -= 1
		l1[2] -= 1
	if l1[1] > 0 and l1[0] > 0 and (l1[2] > 0):
		count += 1
	print(count)


from sys import stdin
T = int(input())
for _ in range(T):
	(a, b, c) = [int(x) for x in stdin.readline().split()]
	l = [a, b, c]
	total = 0
	for i in range(3):
		if l[i] != 0:
			l[i] -= 1
			total += 1
	m = max(l)
	order = [l.index(m)]
	test = [0, 1, 2]
	test.remove(l.index(m))
	if l[test[0]] > l[test[1]]:
		order.append(test[0])
		order.append(test[1])
	else:
		order.append(test[1])
		order.append(test[0])
	indices = [(0, 1), (0, 2), (1, 2)]
	for (x, y) in indices:
		if l[order[x]] > 0 and l[order[y]] > 0:
			l[order[x]] -= 1
			l[order[y]] -= 1
			total += 1
	zz = True
	for x in l:
		if x == 0:
			zz = False
	if zz:
		total += 1
		for i in range(3):
			l[i] -= 1
	print(total)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	count = 0
	(a, b, c) = invr()
	if a > 0:
		a = a - 1
		count = count + 1
	if b > 0:
		b = b - 1
		count = count + 1
	if c > 0:
		c = c - 1
		count = count + 1
	li = [a, b, c]
	li.sort()
	a = li[2]
	b = li[1]
	c = li[0]
	if a > 0 and b > 0:
		a = a - 1
		b = b - 1
		count = count + 1
	if a > 0 and c > 0:
		a = a - 1
		c = c - 1
		count = count + 1
	if b > 0 and c > 0:
		b = b - 1
		c = c - 1
		count = count + 1
	if a > 0 and b > 0 and (c > 0):
		count = count + 1
	print(count)


t = int(input())
for ts in range(t):
	a = [int(x) for x in input().split()]
	res = 0
	if a[0]:
		a[0] -= 1
		res += 1
	if a[1]:
		a[1] -= 1
		res += 1
	if a[2]:
		a[2] -= 1
		res += 1
	if a[0] == 1 and a[1] == 1 and (a[2] > 1):
		res += 2
		a[0] -= 1
		a[1] -= 1
		a[2] -= 2
	else:
		if a[0] and a[1]:
			a[0] -= 1
			a[1] -= 1
			res += 1
		if a[0] and a[2]:
			a[0] -= 1
			a[2] -= 1
			res += 1
		if a[1] and a[2]:
			a[2] -= 1
			a[1] -= 1
			res += 1
	res += bool(a[0] and a[1] and a[2])
	print(res)


t = int(input())
for i in range(t):
	abc = list(map(int, input().split()))
	abc.sort()
	ans = 0
	if abc[0] >= 4:
		ans = 7
	elif abc[0] >= 3:
		ans = 6
	elif abc[0] >= 2 and abc[2] >= 3:
		ans = 5
	elif abc[0] >= 2:
		ans = 4
	elif abc[0] >= 1 and abc[1] >= 2 and (abc[2] >= 2):
		ans = 4
	elif abc[0] >= 1 and abc[2] >= 1:
		ans = 3
	elif abc[0] == 0 and abc[1] >= 2:
		ans = 3
	elif abc[0] == 0 and abc[1] >= 1 and (abc[2] >= 1):
		ans = 2
	elif abc[0] == 0 and abc[1] == 0 and (abc[2] >= 1):
		ans = 1
	print(ans)


def solve():
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == 0 and l[1] == 0 and (l[2] == 0):
		print(0)
	elif l[0] == 0 and l[1] == 0:
		print(1)
	elif l[0] == 0:
		if l[1] >= 2 and l[2] >= 2:
			print(3)
		else:
			print(2)
	elif l[0] == 1 and l[1] == 1:
		print(3)
	elif l[0] == 1:
		print(4)
	elif l[0] == 2:
		if l[1] == 2 and l[2] == 2:
			print(4)
		else:
			print(5)
	elif l[0] == 3:
		print(6)
	else:
		print(7)
	return
T = int(input())
for _ in range(T):
	solve()


from itertools import permutations
lis = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
perm = permutations(lis)
perm = list(perm)

def check(v_1, v_2, v_3):
	c = 0
	for i in range(len(perm)):
		count = 0
		v1 = v_1
		v2 = v_2
		v3 = v_3
		for j in range(7):
			if v1 - perm[i][j][0] >= 0 and v2 - perm[i][j][1] >= 0 and (v3 - perm[i][j][2] >= 0):
				v1 -= perm[i][j][0]
				v2 -= perm[i][j][1]
				v3 -= perm[i][j][2]
				count += 1
		c = max(count, c)
	return c
t = int(input())
for _ in range(t):
	(a, b, c) = [int(i) for i in input().split()]
	val = flag = 0
	ans = check(a, b, c)
	print(ans)


from collections import Counter
from collections import defaultdict as dfd
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))

def solve():
	for _ in range(nin()):
		(a, b, c) = sorted(read())
		if c == 0:
			ans_.append(0)
			continue
		elif a >= 4:
			ans_.append(7)
			continue
		else:
			ans = 0
			if a:
				ans += 1
				a -= 1
			if b:
				ans += 1
				b -= 1
			if c:
				ans += 1
				c -= 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:
				ans += 1
				a -= 1
				b -= 1
			if a:
				ans += 1
				a -= 1
				b -= 1
				c -= 1
			ans_.append(ans)
solve()
for i in ans_:
	print(i)


def translation():
	word_1 = input()
	word_2 = input()[::-1]
	print(['NO', 'YES'][word_1 == word_2])
	return

def anton_and_danik():
	games = int(input())
	wins = input()
	anton_wins = sum((i == 'A' for i in wins))
	if anton_wins * 2 > len(wins):
		print('Anton')
	elif anton_wins * 2 == len(wins):
		print('Friendship')
	else:
		print('Danik')
	return

def acoomodation():
	cnt = 0
	for _ in range(int(input())):
		(p, q) = map(int, input().split())
		if q - p >= 2:
			cnt += 1
	print(cnt)
	return

def juicer():
	(n, b, d) = map(int, input().split())
	sum_orange = 0
	cnt_empty = 0
	for orange in list(map(int, input().split())):
		if orange <= b:
			sum_orange += orange
			if sum_orange > d:
				cnt_empty += 1
				sum_orange = 0
	print(cnt_empty)
	return

def digit_game():
	for game in range(int(input())):
		breach_odd_cnt = 0
		breach_even_cnt = 0
		raze_odd_cnt = 0
		raze_even_cnt = 0
		n = int(input())
		number = input()
		breach_numbers = ''
		raze_numbers = ''
		len_number = len(number)
		idx = 1
		for digit in number:
			if idx % 2 == 0:
				breach_numbers += digit
				if digit in '13579':
					breach_odd_cnt += 1
				else:
					breach_even_cnt += 1
			else:
				raze_numbers += digit
				if digit in '13579':
					raze_odd_cnt += 1
				else:
					raze_even_cnt += 1
			idx += 1
		if len_number == 1:
			if int(number) % 2 == 0:
				print(2)
			else:
				print(1)
		elif len_number % 2 == 0:
			if breach_even_cnt >= 1:
				print(2)
			else:
				print(1)
		elif raze_odd_cnt >= 1:
			print(1)
		else:
			print(2)
	return

def modular_exponentiation():
	n = int(input())
	m = int(input())
	calc = m % int(1 << n)
	print(int(calc))
	return

def tricky_sum():
	for _ in range(int(input())):
		number = int(input())
		pow_two = 1
		while pow_two <= number:
			pow_two *= 2
			print(pow_two)
		sum_formula = number * (number + 1) // 2
		trick_sum = sum_formula - 2 * pow_two + 2
		print(trick_sum)
	return

def three_indices():
	for _ in range(int(input())):
		n = int(input())
		permutation = list(map(int, input().split()))
		(idx_i, idx_j, idx_k) = (1, 2, 3)
		(num_i, num_j, num_k) = (0, 0, 0)
		for idx in range(1, n - 1):
			if permutation[idx] > permutation[idx - 1] and permutation[idx] > permutation[idx + 1]:
				print('YES')
				print(idx, idx + 1, idx + 2)
				break
		else:
			print('NO')
	return

def three_friends():
	for test_cases in range(int(input())):
		coords = list(map(int, input().split()))
		coords_neu = sorted(coords)
		if coords_neu[2] - coords_neu[0] <= 2:
			print(0)
		else:
			print(2 * (coords_neu[2] - coords_neu[0]) - 4)
	return

def decoding():
	length = int(input())
	word = list(input())
	new_word = ''
	for i in range(1, length + 1, 1):
		if len(word) % 2 != 0:
			new_word = new_word + word[0]
		else:
			new_word = word[0] + new_word
		word.pop(0)
	print(new_word)
	return

def cookies():
	number_of_bags = int(input())
	bag_content = list(map(int, input().split()))
	sum_cookies = sum(bag_content)
	cnt_even = 0
	cnt_uneven = 0
	for bag in bag_content:
		if bag % 2 == 0:
			cnt_even += 1
		else:
			cnt_uneven += 1
	if sum_cookies % 2 == 0:
		if cnt_even > 0:
			print(cnt_even)
		else:
			print(0)
	elif cnt_uneven > 0:
		print(cnt_uneven)
	else:
		print(0)
	return

def holidays():
	days = int(input())
	a = days // 7 * 2
	if days % 7 == 6:
		a += 1
	b = (days - 2) // 7 * 2 + 2
	if (days - 2) % 7 == 6:
		b += 1
	print(a, b)
	return

def arrays():
	(A_size, B_size) = map(int, input().split())
	(k, m) = map(int, input().split())
	Array_A = list(map(int, input().split()))
	Array_B = list(map(int, input().split()))
	if Array_A[k - 1] < Array_B[-m]:
		print('YES')
	else:
		print('NO')
	return

def fast_food_restaurant():
	for _ in range(int(input())):
		dishes = sorted(list(map(int, input().split())))
		made_dishes_cnt = 0
		if dishes[2] == 0:
			print(0)
		elif dishes[0] > 3:
			print(7)
		else:
			for (idx, dish) in enumerate(dishes):
				if dish > 0:
					dishes[idx] -= 1
					made_dishes_cnt += 1
			if dishes[0] > 0:
				dishes[0] -= 1
				dishes[2] -= 1
				made_dishes_cnt += 1
			if dishes[0] > 0 and dishes[1] > 0:
				dishes[0] -= 1
				dishes[1] -= 1
				made_dishes_cnt += 1
			if dishes[1] > 0 and dishes[2] > 0:
				dishes[1] -= 1
				dishes[2] -= 1
				made_dishes_cnt += 1
			if dishes[0] > 0 and dishes[1] > 0 and (dishes[2] > 0):
				made_dishes_cnt += 1
			print(made_dishes_cnt)
	return
fast_food_restaurant()


from itertools import chain, combinations

def powerset(iterable):
	s = list(iterable)
	return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))
for _ in range(int(input())):
	a = sorted(list(map(int, input().split())), reverse=True)
	ans = 0
	for choice in powerset(range(3)):
		if len(choice) == 0:
			continue
		elif all([a[i] for i in choice]):
			for i in choice:
				a[i] -= 1
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	tot = 0
	if a > 0:
		a -= 1
		tot += 1
	if b > 0:
		b -= 1
		tot += 1
	if c > 0:
		c -= 1
		tot += 1
	if a > 1 and b > 1 and (c > 1):
		c -= 2
		b -= 2
		a -= 2
		tot += 3
	elif a > 1 and b > 0 and (c > 0):
		a -= 2
		b -= 1
		c -= 1
		tot += 2
	elif a > 0 and b > 1 and (c > 0):
		a -= 1
		b -= 2
		c -= 1
		tot += 2
	elif a > 0 and b > 0 and (c > 1):
		a -= 1
		b -= 1
		c -= 2
		tot += 2
	elif a > 0 and b > 0:
		a -= 1
		b -= 1
		tot += 1
	elif a > 0 and c > 0:
		a -= 1
		c -= 1
		tot += 1
	elif b > 0 and c > 0:
		b -= 1
		c -= 1
		tot += 1
	if a > 0 and b > 0 and (c > 0):
		tot += 1
	print(tot)


def calc_dishes(dishes):
	dishes = ''.join(sorted(map(lambda x: str(min(x, 4)), dishes)))
	if dishes == '000':
		return 0
	if dishes.startswith('00'):
		return 1
	if dishes.startswith('01'):
		return 2
	if dishes.startswith('0') or dishes.startswith('11'):
		return 3
	if dishes >= '122' and dishes <= '222':
		return 4
	if dishes >= '223' and dishes <= '244':
		return 5
	if dishes.startswith('3'):
		return 6
	return 7
rounds = int(input())
for i in range(rounds):
	(a, b, c) = map(int, input().split())
	print(calc_dishes([a, b, c]))


t = int(input())
arr = list()
res = 0

def find(arr):
	global res
	for (ind, k) in enumerate(arr):
		if k != 0:
			res += 1
			arr[ind] -= 1
	sor = sorted(arr, reverse=True)
	if sor[0] and sor[1]:
		res += 1
		sor[0] -= 1
		sor[1] -= 1
	if sor[0] and sor[2]:
		res += 1
		sor[0] -= 1
		sor[2] -= 1
	if sor[1] and sor[2]:
		res += 1
		sor[1] -= 1
		sor[2] -= 1
	if sor[0] and sor[1] and sor[2]:
		res += 1
	print(res)
for i in range(t):
	arr = list(map(int, input().split()))
	find(arr)
	res = 0


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	result = 0
	if a > 0:
		a -= 1
		result += 1
	if b > 0:
		b -= 1
		result += 1
	if c > 0:
		c -= 1
		result += 1
	arr = sorted([a, b, c])
	if arr[2] >= 2:
		if arr[0] > 0:
			arr[0] -= 1
			arr[2] -= 1
			result += 1
		if arr[1] > 0:
			arr[1] -= 1
			arr[2] -= 1
			result += 1
		if arr[0] > 0 and arr[1] > 0:
			arr[0] -= 1
			arr[1] -= 1
			result += 1
	elif arr[2] == 1:
		if arr[1] > 0:
			arr[1] -= 1
			arr[2] -= 1
			result += 1
		if arr[0] > 0 and arr[1] > 0:
			arr[0] -= 1
			arr[1] -= 1
			result += 1
	if min(arr) > 0:
		result += 1
	print(result)


inputNum = int(input())
ansList = []
for i in range(inputNum):
	countList = [0, 0, 0, 0, 0]
	num = [int(n) for n in input().split()]
	for j in num:
		if j > 4:
			j = 4
		for k in range(j + 1):
			countList[k] += 1
	if countList[4] == 3:
		ansList.append(7)
		continue
	if countList[3] == 3:
		ansList.append(6)
		continue
	if countList[2] == 3 and countList[3] > 0:
		ansList.append(5)
		continue
	if countList[1] == 3 and countList[2] > 1:
		ansList.append(4)
		continue
	if countList[1] == 3 or countList[2] > 1:
		ansList.append(3)
		continue
	ansList.append(countList[1])
for i in ansList:
	print(i)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(a, b, c) = [int(x) for x in input().split()]
		lst = [a, b, c]
		count0 = lst.count(0)
		count1 = lst.count(1)
		count2 = lst.count(2)
		count3 = lst.count(3)
		minx = min(lst)
		maxx = max(lst)
		sumx = sum(lst)
		midx = sumx - maxx - minx
		if minx >= 4:
			yield 7
		elif minx == 3:
			yield 6
		elif minx == 2:
			if maxx >= 3:
				yield 5
			else:
				yield 4
		elif minx == 1:
			if maxx >= 2:
				if midx >= 2:
					yield 4
				else:
					yield 3
			else:
				yield 3
		elif maxx >= 2:
			if midx >= 2:
				yield 3
			elif midx == 1:
				yield 2
			else:
				yield 1
		elif maxx == 1:
			if midx == 1:
				yield 2
			else:
				yield 1
		else:
			yield 0
t = int(input())
ans = gift()
print(*ans, sep='\n')


n = int(input())
Result = []
for i in range(0, n):
	count = 0
	permutation = 0
	List = list(map(int, input().strip().split()))[0:3]
	for j in range(0, 3):
		if List[j] > 0:
			List[j] -= 1
			count += 1
	permutation = count
	count_0 = 0
	count_1 = 0
	countOther = 0
	if count >= 2:
		for j in range(0, 3):
			if List[j] == 0:
				count_0 += 1
			elif List[j] == 1:
				count_1 += 1
			elif List[j] >= 3:
				countOther += 1
		if count_0 == 3:
			permutation += 0
		elif count_0 == 2:
			permutation += 0
		elif count_0 == 1:
			permutation += 1
		elif count_0 == 0:
			if count_1 == 3:
				permutation += 1
			elif count_1 == 2:
				permutation += 2
			elif count_1 == 1:
				permutation += 2
			elif count_1 == 0:
				permutation += 3
		if countOther == 3:
			permutation += 1
		else:
			permutation += 0
	Result.append(permutation)
for i in Result:
	print(i)


from itertools import permutations

def removeDup(x):
	ans = []
	for i in x:
		if i not in ans:
			ans.append(i)
	return ans
possible = list(permutations([0, 0, 1])) + list(permutations([0, 1, 1])) + [(1, 1, 1)]
possible = removeDup(possible)
ans = []
for t in range(int(input())):
	k = [int(i) for i in input().split()]
	k.sort()
	count = 0
	for i in possible:
		prev = k + []
		for j in range(3):
			k[j] -= i[j]
		if k[0] >= 0 and k[1] >= 0 and (k[2] >= 0):
			count += 1
		else:
			k = prev
	ans.append(str(count))
print('\n'.join(ans))


t = int(input())
l1 = []
for i in range(t):
	s = 0
	asc = []
	(a, b, c) = map(int, input().split())
	if a > 0:
		s += 1
		a -= 1
	if b > 0:
		s += 1
		b -= 1
	if c > 0:
		s += 1
		c -= 1
	asc.extend([a, b, c])
	asc.sort(reverse=True)
	if asc[0] > 0 and asc[2] > 0:
		s += 1
		asc[0] -= 1
		asc[2] -= 1
	if asc[0] > 0 and asc[1] > 0:
		s += 1
		asc[0] -= 1
		asc[1] -= 1
	if asc[1] > 0 and asc[2] > 0:
		s += 1
		asc[2] -= 1
		asc[1] -= 1
	if asc[0] > 0 and asc[1] > 0 and (asc[2] > 0):
		s += 1
	l1.append(s)
for item in l1:
	print(item)


def solve(a, b, c):
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	if min(a, b) > 0:
		ans += 1
		a -= 1
		b -= 1
	if min(b, c) > 0:
		ans += 1
		b -= 1
		c -= 1
	if min(a, c) > 0:
		ans += 1
		a -= 1
		c -= 1
	if min(a, b, c) > 0:
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	return ans
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(max(solve(a, b, c), solve(a, c, b), solve(b, c, a), solve(b, a, c), solve(c, a, b), solve(c, b, a)))


import math, collections, sys
input = sys.stdin.readline

def solve():
	count = 0
	a = list(map(int, input().split()))
	a.sort()
	for i in range(1, 8):
		d = bin(i)[2:].zfill(3)
		flag = True
		for i in range(3):
			if d[i] == '1':
				if not a[i]:
					flag = False
		if flag:
			for i in range(3):
				if d[i] == '1':
					a[i] -= 1
			count += 1
	print(count)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	X = [a, b, c]
	X.sort(reverse=True)
	(d, e, f) = X
	if d > 0 and e > 0:
		d -= 1
		e -= 1
		count += 1
	if d > 0 and f > 0:
		d -= 1
		f -= 1
		count += 1
	if e > 0 and f > 0:
		e -= 1
		f -= 1
		count += 1
	if d > 0 and e > 0 and (f > 0):
		count += 1
	print(count)


t = int(input())
for i in range(t):
	list = [int(i) for i in input().split()]
	list.sort()
	list.reverse()
	d = 0
	if list[0] > 0:
		d += 1
		list[0] -= 1
	if list[1] > 0:
		d += 1
		list[1] -= 1
	if list[2] > 0:
		d += 1
		list[2] -= 1
	list.sort()
	list.reverse()
	if list[0] > 0 and list[1] > 0:
		d += 1
		list[0] -= 1
		list[1] -= 1
	if list[1] > 0 and list[2] > 0:
		d += 1
		list[1] -= 1
		list[2] -= 1
	if list[0] > 0 and list[2] > 0:
		d += 1
		list[0] -= 1
		list[2] -= 1
	if list[0] > 0 and list[1] > 0 and (list[2] > 0):
		d += 1
		list[0] -= 1
		list[1] -= 1
		list[2] -= 1
	print(d)


from copy import copy
from math import *

def arr_float_inp():
	return [float(s) for s in input().split()]

def arr_int_inp():
	return [int(s) for s in input().split()]

def int_inp():
	return int(input())

def float_inp():
	return float(input())

def comp(a):
	return a[0]

def gcd(a, b):
	if b != 0:
		return gcd(b, a % b)
	else:
		return a
for _ in range(int_inp()):
	(a, b, c) = sorted(arr_int_inp())
	out = 0
	if a > 0:
		out += 1
		a -= 1
	if b > 0:
		out += 1
		b -= 1
	if c > 0:
		out += 1
		c -= 1
	if a > 0 and c > 0:
		out += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		out += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0:
		out += 1
		a -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		out += 1
		a -= 1
		b -= 1
		c -= 1
	print(out)


A = [1, 0, 0, 1, 1, 0, 1]
B = [0, 1, 0, 0, 1, 1, 1]
C = [0, 0, 1, 1, 0, 1, 1]

def f(x, y, z, i):
	if i == 7:
		return 0
	r = f(x, y, z, i + 1)
	if A[i] <= x and B[i] <= y and (C[i] <= z):
		x -= A[i]
		y -= B[i]
		z -= C[i]
		return max(r, 1 + f(x, y, z, i + 1))
	return r
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(f(a, b, c, 0))


for tests in range(int(input())):
	L = list(map(int, input().split()))
	ans = 0
	for i in range(3):
		if L[i] > 0:
			L[i] -= 1
			ans += 1
	if L[1] >= 2 and L[2] >= 2 and (L[0] >= 2):
		ans += 3
		L[0] -= 2
		L[1] -= 2
		L[2] -= 2
	elif L[1] >= 1 and L[2] >= 1 and (L[0] >= 1):
		if L[0] >= 2:
			L[0] -= 2
			L[1] -= 1
			L[2] -= 1
			ans += 2
		elif L[1] >= 2:
			L[0] -= 1
			L[1] -= 2
			L[2] -= 1
			ans += 2
		elif L[2] >= 2:
			L[0] -= 1
			L[1] -= 1
			L[2] -= 2
			ans += 2
		else:
			L[0] -= 1
			L[1] -= 1
			ans += 1
	elif L[0] > 0 and L[1] > 0:
		L[0] -= 1
		L[1] -= 1
		ans += 1
	elif L[1] > 0 and L[2] > 0:
		L[1] -= 1
		L[2] -= 1
		ans += 1
	elif L[0] > 0 and L[2] > 0:
		L[0] -= 1
		L[2] -= 1
		ans += 1
	if L[1] > 0 and L[2] > 0 and (L[0] > 0):
		ans += 1
	print(ans)


for _ in range(int(input())):
	data = list(map(int, input().split()))
	data.sort()
	(a, b, c) = (data[0], data[1], data[2])
	result = 0
	for i in range(0, 2):
		for j in range(0, 2):
			for k in range(0, 2):
				if not i == j == k == 0 and i <= a and (j <= b) and (k <= c):
					a -= i
					b -= j
					c -= k
					result += 1
	print(result)


t = int(input())
for i in range(t):
	d = list(map(int, input().split()))
	d.sort(reverse=True)
	count = 0
	for j in range(len(d)):
		if d[j] > 0:
			d[j] -= 1
			count += 1
	for j in range(len(d)):
		if d[j] > 0 and d[(j + 1) % 3] > 0:
			d[j] -= 1
			d[(j + 1) % 3] -= 1
			count += 1
	if d[0] > 0 and d[1] > 0 and (d[2] > 0):
		count += 1
	print(count)


t = int(input())
for i in range(t):
	count = 0
	(n, m, r) = sorted(map(int, input().split()))[::-1]
	if n >= 1:
		count += 1
		n -= 1
	if m >= 1:
		count += 1
		m -= 1
	if r >= 1:
		count += 1
		r -= 1
	if n >= 1 and m >= 1:
		count += 1
		n -= 1
		m -= 1
	if m >= 1 and r >= 1:
		count += 1
		m -= 1
		r -= 1
	if r >= 1 and n >= 1:
		count += 1
		r -= 1
		n -= 1
	if n >= 1 and m >= 1 and (r >= 1):
		count += 1
		n -= 1
		m -= 1
		r -= 1
	print(count)


T = int(input())
while T != 0:
	ans = 0
	T -= 1
	s = list(map(int, input().split()))
	s = sorted(s, reverse=True)
	if s[0] > 0:
		ans += 1
		s[0] -= 1
	if s[1] > 0:
		s[1] -= 1
		ans += 1
	if s[2] > 0:
		s[2] -= 1
		ans += 1
	if s[0] > 0 and s[1] > 0:
		s[0] -= 1
		s[1] -= 1
		ans += 1
	if s[0] > 0 and s[2] > 0:
		s[0] -= 1
		s[2] -= 1
		ans += 1
	if s[1] > 0 and s[2] > 0:
		s[1] -= 1
		s[2] -= 1
		ans += 1
	if s[0] > 0 and s[1] > 0 and (s[2] > 0):
		ans += 1
	print(ans)


for tc in range(int(input())):
	(*a,) = map(int, input().split())
	a.sort()
	ans = 0
	if a[0] > 0:
		ans += 1
		a[0] -= 1
	if a[1] > 0:
		ans += 1
		a[1] -= 1
	if a[2] > 0:
		ans += 1
		a[2] -= 1
	if a[1] > 0 and a[2] > 0:
		ans += 1
		a[1] -= 1
		a[2] -= 1
	if a[0] > 0 and a[2] > 0:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0 and (a[2] > 0):
		ans += 1
		a[0] -= 1
		a[1] -= 1
		a[2] -= 1
	if a[0] > 0 and a[1] > 0:
		ans += 1
		a[0] -= 1
		a[1] -= 1
	print(ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	abc = get_list()
	abc.sort()
	if abc[0] >= 4:
		print(7)
		return
	if abc[0] == 3:
		print(6)
	if abc[0] == 2:
		if abc[-1] > 2:
			print(5)
		else:
			print(4)
		return
	if abc[0] == 1:
		if abc[1] > 1:
			print(4)
		else:
			print(3)
		return
	if abc[0] == 0:
		if abc[1] > 1:
			print(3)
		elif abc[1] > 0:
			print(2)
		elif abc[-1] >= 1:
			print(1)
		else:
			print(0)
		return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] >= 4:
		print(7)
		continue
	if a[0] == 0:
		if a[1] >= 2:
			print(3)
			continue
		if a[1] == 1:
			print(2)
			continue
		if a[1] == 0:
			if a[2] != 0:
				print(1)
			else:
				print(0)
			continue
	if a[0] == 1:
		if a[1] >= 2:
			print(4)
			continue
		if a[1] == 1:
			print(3)
			continue
	if a[0] == 2:
		if a[1] >= 3:
			print(5)
			continue
		if a[1] == 2:
			if a[2] >= 3:
				print(5)
			else:
				print(4)
			continue
	if a[0] == 3:
		print(6)
		continue


import sys
INF = 10 ** 18
MOD = 10 ** 9 + 7

def input():
	return sys.stdin.readline().rstrip()

def main():
	t = int(input())
	for _ in range(t):
		l = list(map(int, input().split()))
		ans = 0
		for i in range(3):
			if l[i] >= 1:
				l[i] -= 1
				ans += 1
		l.sort()
		if l[0] >= 1 and l[2] >= 1:
			l[0] -= 1
			l[2] -= 1
			ans += 1
		if l[1] >= 1 and l[2] >= 1:
			l[1] -= 1
			l[2] -= 1
			ans += 1
		if l[0] >= 1 and l[1] >= 1:
			l[0] -= 1
			l[1] -= 1
			ans += 1
		if min(l) >= 1:
			ans += 1
		print(ans)
main()


def ini():
	n = input()
	return int(n)
testCase = ini()
while testCase > 0:
	testCase -= 1
	ans = 0
	(a, b, c) = (int(i) for i in input().split())
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	l = [a, b, c]
	l.sort()
	(c, b, a) = l
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		ans += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		ans += 1
	if b > 0 and c > 0:
		c -= 1
		b -= 1
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


tests = int(input())
dishes = []
for i in range(0, tests):
	dishes.append(list(map(int, input().split())))
for i in range(0, tests):
	numbers = dishes[i].copy()
	numbers.sort()
	counter = 0
	for i in range(0, 3):
		if numbers[i] > 0:
			numbers[i] -= 1
			counter += 1
	if numbers[2] > 0 and numbers[1] > 0:
		numbers[2] -= 1
		numbers[1] -= 1
		counter += 1
	if numbers[2] > 0 and numbers[0] > 0:
		numbers[2] -= 1
		numbers[0] -= 1
		counter += 1
	if numbers[1] > 0 and numbers[0] > 0:
		numbers[1] -= 1
		numbers[0] -= 1
		counter += 1
	if numbers[0] > 0 and numbers[1] > 0 and (numbers[2] > 0):
		counter += 1
	print(counter)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	zero = l.count(0)
	one = l.count(1)
	if zero == 3:
		print(0)
	elif zero == 2:
		print(1)
	elif zero == 1:
		if one in [1, 2]:
			print(2)
		else:
			print(3)
	elif zero == 0:
		if one in [2, 3]:
			print(3)
		elif one == 1:
			print(4)
		elif one == 0:
			if l.count(2) == 3:
				print(4)
			elif l.count(2) in [1, 2]:
				print(5)
			elif l.count(3) in [1, 2, 3]:
				print(6)
			else:
				print(7)


t = int(input())
for i in range(t):
	(C, B, A) = sorted(map(int, input().split()))
	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)


from itertools import combinations
masks = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
for _ in range(int(input())):
	l = [*map(int, input().split())]
	done = False
	for n in range(7, -1, -1):
		for m in combinations(masks, n):
			val = [0] * 3
			for mask in m:
				val = [x + y for (x, y) in zip(val, mask)]
			if all((x >= y for (x, y) in zip(l, val))):
				print(n)
				done = True
				break
		if done:
			break


q = int(input())
for t in range(q):
	abc = [int(x) for x in input().split()]
	count = 0
	m = 7
	if abc[0] == 0 and abc[1] == 0 and (abc[2] == 0):
		print(0)
		continue
	if abc[0] > 0:
		abc[0] -= 1
		count += 1
	if abc[1] > 0:
		abc[1] -= 1
		count += 1
	if abc[2] > 0:
		abc[2] -= 1
		count += 1
	abc.sort(reverse=True)
	if abc[0] > 0 and abc[1] > 0:
		abc[0] -= 1
		abc[1] -= 1
		count += 1
	if abc[0] > 0 and abc[2] > 0:
		abc[0] -= 1
		abc[2] -= 1
		count += 1
	if abc[1] > 0 and abc[2] > 0:
		count += 1
		abc[1] -= 1
		abc[2] -= 1
	if abc[0] > 0 and abc[1] > 0 and (abc[2] > 0):
		count += 1
	print(count)


def subsets(l):
	if not l:
		return [[]]
	ll = subsets(l[1:])
	return ll + list(map(lambda u: u + [l[0]], ll))
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split(' '))
	res = 0
	for subset in subsets(list(range(1, 8))):
		(a1, b1, c1, res1) = (a, b, c, 0)
		for x in subset:
			if x % 2 == 1:
				a1 -= 1
			x = x // 2
			if x % 2 == 1:
				b1 -= 1
			x = x // 2
			if x % 2 == 1:
				c1 -= 1
			if a1 >= 0 and b1 >= 0 and (c1 >= 0):
				res1 += 1
		res = max(res, res1)
	print(res)


import math
t = int(input())
for g in range(0, t):
	abc = list(map(int, input().split()))
	a = abc[0]
	b = abc[1]
	c = abc[2]
	result = 0
	if a > 0:
		result += 1
		a = a - 1
	if b > 0:
		result += 1
		b = b - 1
	if c > 0:
		result += 1
		c = c - 1
	x = max(a, b, c)
	y = min(a, b, c)
	z = a + b + c - x - y
	if x > 0 and y > 0:
		result += 1
		x = x - 1
		y = y - 1
	if x > 0 and z > 0:
		result += 1
		x = x - 1
		z = z - 1
	if y > 0 and z > 0:
		result += 1
		z = z - 1
		y = y - 1
	if x > 0 and y > 0 and (z > 0):
		result += 1
	print(result)


t = int(input())
for _ in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	x = 0
	if a > 0:
		x += 1
		a -= 1
	if b > 0:
		x += 1
		b -= 1
	if c > 0:
		x += 1
		c -= 1
	if c != max(a, b, c):
		if a > 0 and b > 0:
			x += 1
			a -= 1
			b -= 1
		if a > 0 and c > 0:
			x += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			x += 1
			c -= 1
			b -= 1
		if a > 0 and b > 0 and (c > 0):
			x += 1
			c -= 1
			b -= 1
			a -= 1
	else:
		if a > 0 and c > 0:
			x += 1
			a -= 1
			c -= 1
		if c > 0 and b > 0:
			x += 1
			c -= 1
			b -= 1
		if a > 0 and b > 0:
			x += 1
			a -= 1
			b -= 1
		if a > 0 and b > 0 and (c > 0):
			x += 1
			c -= 1
			b -= 1
			a -= 1
	print(x)


from sys import stdin
from math import ceil

def func(a, b, c):
	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 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	return ans
for _ in range(int(stdin.readline())):
	arr = sorted(list(map(int, stdin.readline().split())))
	print(func(arr[-1], arr[-2], arr[-3]))


cases = int(input())
for case in range(cases):
	result = 0
	values = list(map(lambda x: int(x), input().split()))
	values.sort()
	for i in range(3):
		if values[i] == 1:
			result += 1
		elif values[i] >= 2:
			if i < 2:
				result += 2
			else:
				result += 1
	if values[0] > 3:
		result += 2
	if values[0] == 2 and values[-1] == 2:
		result -= 1
	if values[0] == 3:
		result += 1
	print(result)


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


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	count1 = 0
	count = 0
	k = [a, b, c]
	for i in k:
		if i > 0:
			count1 += 1
	if count1 == 0:
		print(0)
		continue
	if count1 == 1:
		print(1)
		continue
	if count1 == 2:
		count += 2
	elif count1 == 3:
		count += 3
	for i in range(3):
		if k[i] != 0:
			k[i] -= 1
	count2 = 0
	if k.count(0) == 1:
		count += 1
		print(count)
		continue
	elif k.count(0) > 1:
		print(count)
		continue
	for i in range(3):
		if k[i] > 1:
			count2 += 1
	if count2 == 0:
		count += 1
	elif count2 == 1 or count2 == 2:
		count += 2
	elif count2 == 3:
		count += 3
	for i in range(3):
		if k[i] != 0:
			k[i] -= 1
	count3 = 0
	for i in range(3):
		if k[i] > 1:
			count3 += 1
	if count3 == 3:
		count += 1
		print(count)
		continue
	print(count)


t = int(input())
for _ in range(t):
	f = list(map(int, input().split()))
	k = -1
	f.sort()
	a = f[0]
	b = f[1]
	c = f[2]
	for a1 in [0, 1]:
		for b1 in [0, 1]:
			for c1 in [0, 1]:
				a -= a1
				b -= b1
				c -= c1
				if a >= 0 and b >= 0 and (c >= 0):
					k += 1
				else:
					a += a1
					b += b1
					c += c1
	print(k)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	count = 0
	l = [a, b, c]
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	for i in range(len(s)):
		a1 = a - s[i][0]
		b1 = b - s[i][1]
		c1 = c - s[i][2]
		if a1 >= 0 and b1 >= 0 and (c1 >= 0):
			count += 1
			a = a - s[i][0]
			b = b - s[i][1]
			c = c - s[i][2]
	print(count)


T = int(input())
for i in range(T):
	(a, b, c) = sorted(list(map(int, input().split())), reverse=True)
	count = 0
	if a > 0:
		a -= 1
		count += 1
	if b > 0:
		b -= 1
		count += 1
	if c > 0:
		c -= 1
		count += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		count += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		count += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		count += 1
	if a > 0 and b > 0 and (c > 0):
		count += 1
	print(count)


import itertools

def solve(sequence, arr):
	arr1 = arr[:]
	count = 0
	for i in sequence:
		if arr1[i[0]] > 0 and arr1[i[1]] > 0:
			arr1[i[0]] -= 1
			arr1[i[1]] -= 1
			count += 1
	return (count, arr1)
for _ in range(int(input())):
	arr = list(map(int, input().split()))
	count = 0
	for i in range(3):
		if arr[i] > 0:
			arr[i] -= 1
			count += 1
	sequences = list(itertools.permutations([(0, 1), (1, 2), (0, 2)]))
	maxx = -1
	arr1 = []
	for sequence in sequences:
		(c, arr2) = solve(sequence, arr)
		if c > maxx:
			maxx = c
			arr1 = arr2
	count += maxx
	arr = arr1
	if min(arr) > 0:
		count += 1
	print(count)


t = int(input())
for z in range(t):
	x = [int(i) for i in input().split()]
	a = x[0]
	b = x[1]
	c = x[2]
	d = {}
	if c > a:
		(a, c) = (c, a)
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	d = {}
	str = 'a' * a + 'b' * b + 'c' * c
	for i in range(len(str) - 1):
		if str[i] != str[i + 1]:
			if str[i] == 'a' and str[i + 1] == 'b' or (str[i] == 'b' and str[i + 1] == 'a'):
				if a > 0 and b > 0:
					ans += 1
					a -= 1
					b -= 1
			if str[i] == 'b' and str[i + 1] == 'c' or (str[i] == 'c' and str[i + 1] == 'b'):
				if b > 0 and c > 0:
					ans += 1
					b -= 1
					c -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	for i in d:
		ans += 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	arr = [int(x) for x in sys.stdin.readline().split()]
	arr.sort(reverse=True)
	a = arr[0]
	b = arr[1]
	c = arr[2]
	tot = 0
	if a > 0:
		tot += 1
		a -= 1
	if b > 0:
		tot += 1
		b -= 1
	if c > 0:
		tot += 1
		c -= 1
	if a > 0 and b > 0:
		tot += 1
		a -= 1
		b -= 1
	if b > 0 and c > 0:
		tot += 1
		b -= 1
		c -= 1
	if a > 0 and c > 0:
		tot += 1
		a -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		tot += 1
		a -= 1
		b -= 1
		c -= 1
	print(tot)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	count = 0
	for j in range(3):
		if l[j] > 4:
			l[j] = 4
	l.sort()
	for k in range(3):
		if l[k] > 0:
			l[k] -= 1
			count += 1
	if l[2] > 0 and l[1] > 0:
		count += 1
		l[2] -= 1
		l[1] -= 1
	if l[2] > 0 and l[0] > 0:
		count += 1
		l[2] -= 1
		l[0] -= 1
	if l[0] > 0 and l[1] > 0:
		count += 1
		l[0] -= 1
		l[1] -= 1
	if l[0] > 0 and l[1] > 0 and (l[2] > 0):
		count += 1
	print(count)


t = int(input())
for _ in range(t):
	ans = 0
	at = list(map(int, input().split()))
	a = max(at)
	at.pop(at.index(a))
	c = min(at)
	at.pop(at.index(c))
	b = at[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 and b > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and c > 0:
		ans += 1
		b -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	print(ans)


import sys
from collections import Counter
from itertools import combinations, permutations

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check(A, comb):
	for a in comb:
		A[a] -= 1
	if min(A) < 0:
		return False
	else:
		return True
for _ in range(INT()):
	A = LIST()
	combs = []
	for i in range(2, 4):
		for comb in combinations(range(3), i):
			combs.append(comb)
	ans = 0
	for perm in permutations(combs):
		cnt = 0
		tmpA = A[:]
		for i in range(3):
			if tmpA[i] >= 1:
				tmpA[i] -= 1
				cnt += 1
		for comb in perm:
			if check(tmpA, comb):
				cnt += 1
			else:
				break
		ans = max(ans, cnt)
	print(ans)


def funct(a, count):
	a -= 1
	if a >= 0:
		return (count + 1, a)

def revolt(l):
	count = 0
	l.sort()
	(a, b, c) = l[::-1]
	if a > 0:
		count += 1
		a -= 1
	if b > 0:
		count += 1
		b -= 1
	if c > 0:
		count += 1
		c -= 1
	if min(a, b) > 0:
		count += 1
		a -= 1
		b -= 1
	if min(c, b) > 0:
		count += 1
		c -= 1
		b -= 1
	if min(a, c) > 0:
		count += 1
		a -= 1
		c -= 1
	if min(a, b, c) > 0:
		count += 1
	return count
for _ in range(int(input())):
	l = list(map(int, input().split()))
	print(revolt(l))


def solve():
	(a, b, c) = sorted(map(int, input().split()), reverse=True)
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a * b > 0:
		a -= 1
		b -= 1
		ans += 1
	if a * c > 0:
		a -= 1
		c -= 1
		ans += 1
	if b * c > 0:
		b -= 1
		c -= 1
		ans += 1
	if a * b * c > 0:
		a -= 1
		b -= 1
		c -= 1
		ans += 1
	print(ans)
n = int(input())
for i in range(n):
	solve()


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
t = I()
for _ in range(t):
	ans = 0
	l = LI()
	l.sort()
	(a, b, c) = l
	for i in range(1, 2 ** 3):
		bit = [0] * 3
		for j in range(3):
			if i >> j & 1:
				bit[-(j + 1)] = 1
		f = [False] * 3
		for j in range(3):
			if j == 0 and bit[j]:
				if a == 0:
					break
				f[j] = True
			elif j == 1 and bit[j]:
				if b == 0:
					break
				f[j] = True
			elif j == 2 and bit[j]:
				if c == 0:
					break
				f[j] = True
		else:
			for j in range(3):
				if j == 0 and f[j]:
					a -= 1
				if j == 1 and f[j]:
					b -= 1
				if j == 2 and f[j]:
					c -= 1
			ans += 1
	print(ans)


for i in range(int(input())):
	shit = [int(_) for _ in input().split()]
	a1 = 0
	a2 = 0
	a3 = 0
	b1 = 0
	b2 = 0
	b3 = 0
	c1 = 0
	shit.sort(reverse=True)
	if shit[0] > 0:
		a1 += 1
		shit[0] -= 1
	if shit[1] > 0:
		a2 += 1
		shit[1] -= 1
	if shit[2] > 0:
		a3 += 1
		shit[2] -= 1
	shit.sort(reverse=True)
	if shit[0] > 0 and shit[1] > 0:
		b1 += 1
		shit[0] -= 1
		shit[1] -= 1
	if shit[1] > 0 and shit[2] > 0:
		b2 += 1
		shit[1] -= 1
		shit[2] -= 1
	if shit[2] > 0 and shit[0] > 0:
		b3 += 1
		shit[0] -= 1
		shit[2] -= 1
	if shit[0] * shit[1] * shit[2] > 0:
		c1 += 1
	print(a1 + a2 + a3 + b1 + b2 + b3 + c1)


for t in range(int(input())):
	values = list(map(int, input().split()))
	count = 0
	if values[0] >= 1:
		count += 1
		values[0] -= 1
	if values[1] >= 1:
		count += 1
		values[1] -= 1
	if values[2] >= 1:
		count += 1
		values[2] -= 1
	values.sort(reverse=True)
	if values[0] >= 1 and values[1] >= 1:
		count += 1
		values[0] -= 1
		values[1] -= 1
	if values[0] >= 1 and values[2] >= 1:
		count += 1
		values[0] -= 1
		values[2] -= 1
	if values[2] >= 1 and values[1] >= 1:
		count += 1
		values[2] -= 1
		values[1] -= 1
	if values[0] >= 1 and values[1] >= 1 and (values[2] >= 1):
		count += 1
	print(count)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
sys.setrecursionlimit(10 ** 6)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	l = [a, b, c]
	l.sort(reverse=True)
	(a, b, c) = l
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		ans += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		ans += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		ans += 1
	if a > 0 and c > 0 and (b > 0):
		ans += 1
	print(ans)


t = int(input())
vars = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
for _ in range(t):
	a = sorted(list(map(int, input().split())), reverse=True)
	guests_fed = 0
	for var in vars:
		if a[0] >= var[0] and a[1] >= var[1] and (a[2] >= var[2]):
			guests_fed += 1
			a[0] -= var[0]
			a[1] -= var[1]
			a[2] -= var[2]
	print(guests_fed)


def portions(a, b, c):
	result = 0
	lista = [a, b, c]
	lista.sort()
	b = lista[0]
	c = lista[1]
	a = lista[2]
	if a >= 1:
		a = a - 1
		result += 1
	if b >= 1:
		b = b - 1
		result += 1
	if c >= 1:
		c = c - 1
		result += 1
	if a >= 1 and b >= 1:
		a = a - 1
		b = b - 1
		result += 1
	if a >= 1 and c >= 1:
		a = a - 1
		c = c - 1
		result += 1
	if b >= 1 and c >= 1:
		b = b - 1
		c = c - 1
		result += 1
	if a >= 1 and b >= 1 and (c >= 1):
		result += 1
	return result
n = int(input())
for i in range(n):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	print(portions(a, b, c))


import sys
input = sys.stdin.readline
D = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
vl = [0] * 7
TC = int(input())
r = []
while TC:
	cnt = 0
	TC -= 1
	nl = list(map(int, input().split()))
	for i in range(3):
		if nl[i]:
			nl[i] -= 1
			cnt += 1
	nl.sort()
	if nl[2] and nl[1]:
		nl[2] -= 1
		nl[1] -= 1
		cnt += 1
	if nl[2] and nl[0]:
		nl[2] -= 1
		nl[0] -= 1
		cnt += 1
	if nl[1] and nl[0]:
		nl[1] -= 1
		nl[0] -= 1
		cnt += 1
	if nl[0] and nl[1] and nl[2]:
		cnt += 1
	r.append(str(cnt))
print('\n'.join(r))


def restaurant(n):

	def cost(d):
		dinners = {1: [0, 0, 1], 2: [0, 1, 0], 3: [1, 0, 0], 4: [0, 1, 1], 5: [1, 1, 0], 6: [1, 0, 1], 7: [1, 1, 1]}
		result = [0, 0, 0]
		count = 0
		for i in range(1, len(d) + 1):
			if d[i - 1] == 1:
				count += 1
				for j in range(len(result)):
					result[j] += dinners[i][j]
		return (count, result)
	n = n.split()
	n1 = int(n[0])
	n2 = int(n[1])
	n3 = int(n[2])
	t = []
	for i in range(128):
		b = list(map(int, bin(i)[2:]))
		while len(b) != 7:
			b.insert(0, 0)
		(c, [x, y, z]) = cost(b)
		if n1 >= x and n2 >= y and (n3 >= z):
			t.append(c)
	return max(t)
f = int(input().strip())
for i in range(f):
	print(restaurant(input().strip()))


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] >= 4 and a[1] >= 4 and (a[2] >= 4):
		print(7)
	elif a[0] >= 3 and a[1] >= 3 and (a[2] >= 3):
		print(6)
	elif a[0] >= 2 and a[1] >= 2 and (a[2] >= 3):
		print(5)
	elif a[0] >= 1 and a[1] >= 2 and (a[2] >= 2):
		print(4)
	elif a[0] >= 1 and a[1] >= 1 and (a[2] >= 1):
		print(3)
	elif a[0] >= 0 and a[1] >= 2 and (a[2] >= 2):
		print(3)
	elif a[0] >= 0 and a[1] >= 1 and (a[2] >= 1):
		print(2)
	elif a[0] >= 0 and a[1] >= 0 and (a[2] >= 1):
		print(1)
	else:
		print(0)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort(reverse=True)
	(a, b, c) = (l[0], l[1], l[2])
	cnt = 0
	if a > 0:
		cnt += 1
		a -= 1
	if b > 0:
		cnt += 1
		b -= 1
	if c > 0:
		cnt += 1
		c -= 1
	if a > 0 and b > 0:
		cnt += 1
		a -= 1
		b -= 1
	if b > 0 and c > 0:
		cnt += 1
		c -= 1
		b -= 1
	if a > 0 and c > 0:
		cnt += 1
		a -= 1
		c -= 1
	if a > 0 and b > 0 and (c > 0):
		cnt += 1
		a -= 1
		b -= 1
		c -= 1
	print(cnt)


from math import ceil
for i in range(int(input())):
	a = sorted(list(map(int, input().split())), reverse=True)
	res = 0
	if a[0] != 0:
		a[0] -= 1
		res += 1
	if a[1] != 0:
		a[1] -= 1
		res += 1
	if a[2] != 0:
		a[2] -= 1
		res += 1
	if a[0] != 0 and a[1] != 0:
		a[0] -= 1
		a[1] -= 1
		res += 1
	if a[0] != 0 and a[2] != 0:
		a[0] -= 1
		a[2] -= 1
		res += 1
	if a[1] != 0 and a[2] != 0:
		a[1] -= 1
		a[2] -= 1
		res += 1
	if a[0] != 0 and a[1] != 0 and (a[2] != 0):
		a[0] -= 1
		a[1] -= 1
		a[2] -= 1
		res += 1
	print(res)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	ans = 0
	(a, b, c) = [int(item) for item in input().split()]
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	array = [a, b, c]
	array.sort()
	if a >= 2 and b >= 2 and (c >= 2):
		ans += 3
		array[0] -= 2
		array[1] -= 2
		array[2] -= 2
	elif array[2] >= 2 and array[0] != 0 and (array[1] != 0):
		array[0] -= 1
		array[1] -= 1
		array[2] -= 2
		ans += 2
	elif array[1] >= 1 and array[2] >= 1:
		array[1] -= 1
		array[2] -= 1
		ans += 1
	if array[0] > 0 and array[1] > 0 and (array[2] > 0):
		ans += 1
	print(ans)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from functools import *
from itertools import permutations, combinations, groupby
import sys
import bisect
import string
import math
import time
import random

def Golf():
	(*a,) = map(int, open(0))

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}):
	mp = [1] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [1] + [mp_def[j] for j in s] + [1]
	mp += [1] * (w + 2)
	return (h + 2, w + 2, mp, found)

def bit_combination(k, n=2):
	rt = []
	for tb in range(n ** k):
		s = [tb // n ** bt % n for bt in range(k)]
		rt += [s]
	return rt

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	import random
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)

def ran_input():
	import random
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)
show_flg = False
show_flg = True
ans = 0
t = I()
st = bit_combination(3, 2)[1:]
for _ in range(t):
	ans = 0
	(a, b, c) = LI()
	for i in range(1 << 7):
		(x, y, z) = (a, b, c)
		cnt = 0
		for j in range(7):
			if i >> j & 1:
				cnt += 1
				(p, q, r) = st[j]
				x -= p
				y -= q
				z -= r
		if x >= 0 and y >= 0 and (z >= 0):
			ans = max(ans, cnt)
	print(ans)


import itertools
cases = int(input())
possible = [i for i in range(1, 8)]
for i in range(cases):
	(o_a, o_b, o_c) = map(int, input().split())
	max_client = 0
	for perm in itertools.permutations(possible):
		(a, b, c) = (o_a, o_b, o_c)
		i = 0
		while i < len(perm) and int(perm[i] & 4 != 0) <= a and (int(perm[i] & 2 != 0) <= b) and (int(perm[i] & 1 != 0) <= c):
			a -= int(perm[i] & 4 != 0)
			b -= int(perm[i] & 2 != 0)
			c -= int(perm[i] & 1 != 0)
			i += 1
		max_client = max(max_client, i)
	print(max_client)


import sys
input = sys.stdin.readline
n = int(input())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	a.append(b)
for i in a:
	i.sort()
	p = 0
	for j in range(3):
		if i[j] > 0:
			i[j] += -1
			p += 1
	for j in range(2):
		if i[j] > 0 and i[2] > 0:
			i[j] += -1
			i[2] += -1
			p += 1
	if i[0] > 0:
		i[0] += -1
		i[1] += -1
		p += 1
	if i[0] > 0:
		p += 1
	print(p)


def count(t, e):
	n = 0
	for b in e:
		t2 = tuple((b >> i & 1 for i in range(0, 3)))
		if all((x >= y for (x, y) in zip(t, t2))):
			t = tuple((x - y for (x, y) in zip(t, t2)))
			n += 1
	return n
for _ in range(int(input())):
	t = tuple(map(int, input().split()))
	print(max(count(t, (1, 2, 4, 3, 5, 6, 7)), count(t, (1, 2, 4, 6, 5, 3, 7))))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	f = [a, b, c]
	f.sort(reverse=True)
	a = f[0]
	b = f[1]
	c = f[2]
	E = 0
	if a != 0:
		E += 1
		a -= 1
	if b != 0:
		E += 1
		b -= 1
	if c != 0:
		E += 1
		c -= 1
	if a != 0 and b != 0:
		E += 1
		a -= 1
		b -= 1
	if a != 0 and c != 0:
		E += 1
		a -= 1
		c -= 1
	if b != 0 and c != 0:
		E += 1
		b -= 1
		c -= 1
	if a != 0 and b != 0 and (c != 0):
		E += 1
	print(E)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	t = 0
	if a:
		t += 1
		a -= 1
	if b:
		t += 1
		b -= 1
	if c:
		t += 1
		c -= 1
	x = max(a, b, c)
	z = min(a, b, c)
	y = a + b + c - (x + z)
	if x and y:
		x -= 1
		y -= 1
		t += 1
	if x and z:
		x -= 1
		z -= 1
		t += 1
	if y and z:
		y -= 1
		z -= 1
		t += 1
	if x and y and z:
		x -= 1
		y -= 1
		z -= 1
		t += 1
	print(t)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(a, b, c) = sorted(mi())
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	if b and c:
		ans += 1
		c -= 1
		b -= 1
	if a and c:
		ans += 1
		a -= 1
		c -= 1
	if b and a:
		ans += 1
		b -= 1
		a -= 1
	if a and b and c:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	arr.sort()
	count = 0
	a = arr[0]
	b = arr[1]
	c = arr[2]
	if arr[0] > 0 and arr[1] > 0 and (arr[2] > 0):
		count += 3
		arr[0] -= 1
		arr[1] -= 1
		arr[2] -= 1
		if arr[0] > 1 and arr[1] > 1 and (arr[2] > 1):
			count += 3
			arr[0] -= 2
			arr[1] -= 2
			arr[2] -= 2
			if arr[0] > 0 and arr[1] > 0 and (arr[2] > 0):
				count += 1
				print(count)
			else:
				print(count)
		else:
			for i in range(3):
				if arr[i] > 2:
					arr[i] = 2
			if arr == [0, 0, 1] or arr == [0, 0, 2] or arr == [0, 0, 0]:
				print(count)
			elif arr == [0, 1, 1] or arr == [0, 1, 2] or arr == [0, 2, 2] or (arr == [1, 1, 1]):
				print(count + 1)
			elif arr == [1, 1, 2] or arr == [1, 2, 2]:
				print(count + 2)
	else:
		for i in range(3):
			if arr[i] > 2:
				arr[i] = 2
		if arr == [0, 0, 0]:
			print(0)
		elif arr == [0, 0, 1] or arr == [0, 0, 2]:
			print(1)
		elif arr == [0, 1, 1] or arr == [0, 1, 2]:
			print(2)
		elif arr == [0, 2, 2]:
			print(3)


for _ in range(int(input())):
	A = list(map(int, input().split()))
	ans = 0
	for i in range(3):
		if A[i] != 0:
			A[i] -= 1
			ans += 1
	A.sort(reverse=True)
	for i in range(1, 3):
		if A[i] != 0 and A[0] != 0:
			A[i] -= 1
			A[0] -= 1
			ans += 1
	if A[1] != 0 and A[2] != 0:
		A[1] -= 1
		A[2] -= 1
		ans += 1
	if min(A) != 0:
		ans += 1
	print(ans)


check = [[0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
for _ in range(int(input())):
	a = list(map(int, input().split()))
	if a[0] >= 4 and a[1] >= 4 and (a[2] >= 4):
		print(7)
	else:
		count = 0
		a.sort()
		if a[0] > 0:
			count += 1
			a[0] -= 1
		if a[1] > 0:
			count += 1
			a[1] -= 1
		if a[2] > 0:
			count += 1
			a[2] -= 1
		if a[2] > 0 and a[0] > 0:
			count += 1
			a[0] -= 1
			a[2] -= 1
		if a[2] > 0 and a[1] > 0:
			count += 1
			a[1] += 1
			a[2] += 1
		if a[1] > 0 and a[0] > 0:
			count += 1
			a[0] -= 1
			a[1] -= 1
		if a[2] >= 0 and a[1] > 0 and (a[0] > 0):
			count += 1
			a[0] -= 1
			a[1] -= 1
			a[2] -= 1
		print(count)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def bs(a, l, h, x):
	while l < h:
		mid = (l + h) // 2
		if a[mid] == x:
			return mid
		if a[mid] < x:
			l = mid + 1
		else:
			h = mid
	return l

def sieve(a):
	for i in range(3, 10 ** 6 + 1, 2):
		a[i] = 1
	for i in range(3, 10 ** 6 + 1, 2):
		for j in range(i * i, 10 ** 6 + 1, i):
			a[j] = 0
	a[2] = 1
	return a

def bfs(g, st):
	visited = [-1] * len(g)
	visited[st] = 0
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == -1:
				visited[i] = visited[s] + 1
				queue.append(i)
	return visited

def dfsusingstack(v, st):
	d = deque([])
	visited = [0] * len(v)
	d.append(st)
	new = []
	visited[st] = 1
	while len(d) != 0:
		curr = d.pop()
		new.append(curr)
		for i in v[curr]:
			if visited[i] == 0:
				visited[i] = 1
				d.append(i)
	return new

def solve():
	(a, b, c) = sep()
	if a == 3 and b == 3 and (c == 3):
		print(6)
		return
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
		return
	arr = [a, b, c]
	arr = sorted(arr)
	if arr.count(0) == 0 and arr.count(1) == 0 and (arr.count(2) == 0):
		print(6)
		return
	ans = 0
	if a > 0:
		a -= 1
		ans += 1
	if b > 0:
		b -= 1
		ans += 1
	if c > 0:
		c -= 1
		ans += 1
	if a != 0 and b != 0 and (c != 0):
		if a == 1 and b == 1 and (c == 1):
			ans += 1
		else:
			ans += 2
	else:
		arr = [a, b, c]
		arr = sorted(arr)
		if arr.count(0) == 1:
			ans += 1
	print(ans)
testcase(int(inp()))


for _ in range(int(input())):
	A = sorted([int(x) for x in input().split()], reverse=True)
	answer = 0
	for i in range(3):
		if A[i] > 0:
			A[i] -= 1
			answer += 1
	for i in range(2):
		for j in range(i + 1, 3):
			if A[i] * A[j] > 0:
				A[i] -= 1
				A[j] -= 1
				answer += 1
	if all((A[i] > 0 for i in range(3))):
		answer += 1
	print(answer)


def solve():
	case = int(input())
	for _t in range(case):
		li = list(map(int, input().split()))
		li.sort(reverse=True)
		a = li[0]
		b = li[1]
		c = li[2]
		ans = 0
		if a >= 1:
			ans += 1
			a -= 1
		if b >= 1:
			ans += 1
			b -= 1
		if c >= 1:
			ans += 1
			c -= 1
		if a >= 1 and b >= 1:
			a -= 1
			b -= 1
			ans += 1
		if a >= 1 and c >= 1:
			a -= 1
			c -= 1
			ans += 1
		if c >= 1 and b >= 1:
			c -= 1
			b -= 1
			ans += 1
		if a >= 1 and b >= 1 and (c >= 1):
			ans += 1
		print(ans)
solve()


import sys
input = sys.stdin.readline
from collections import *
from itertools import *
t = int(input())
l = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	for li in permutations(l):
		cnt = 0
		a_now = a
		b_now = b
		c_now = c
		for (s1, s2, s3) in li:
			if a_now - s1 >= 0 and b_now - s2 >= 0 and (c_now - s3 >= 0):
				a_now -= s1
				b_now -= s2
				c_now -= s3
				cnt += 1
		ans = max(ans, cnt)
	print(ans)


for T in range(int(input())):
	x = list(map(int, input().split(' ')))
	x.sort(reverse=True)
	a = x[0]
	b = x[1]
	c = x[2]
	ans = 0
	if a >= 1:
		ans += 1
		a -= 1
	if b >= 1:
		ans += 1
		b -= 1
	if c >= 1:
		ans += 1
		c -= 1
	if a >= 1 and b >= 1:
		a -= 1
		b -= 1
		ans += 1
	if a >= 1 and c >= 1:
		a -= 1
		c -= 1
		ans += 1
	if b >= 1 and c >= 1:
		b -= 1
		c -= 1
		ans += 1
	if a >= 1 and b >= 1 and (c >= 1):
		ans += 1
	print(ans)


t = int(input())
dishes = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
for i in range(t):
	s = sorted(list(map(int, input().split())))
	c = 0
	for d in dishes:
		a = [s[i] - d[i] for i in range(3)]
		if all((j >= 0 for j in a)):
			c += 1
			s = a
	print(c)


import math
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	if min(c, a) > 0:
		ans += 1
		a -= 1
		c -= 1
	if min(c, b) > 0:
		ans += 1
		c -= 1
		b -= 1
	if min(a, b) > 0:
		ans += 1
		a -= 1
		b -= 1
	if min(a, b, c) > 0:
		ans += 1
		a -= 1
		b -= 1
		c -= 1
	print(ans)


t = int(input())
for i in range(t):
	l = [int(z) for z in input().split(' ')]
	l.sort()
	(a, b, c) = l
	a = l[2]
	b = l[1]
	c = l[0]
	ans = 0
	(a1, b1, c1, ab1, bc1, ca1, abc1) = (0, 0, 0, 0, 0, 0, 0)
	if a > 0 and a1 == 0:
		ans = ans + 1
		a = a - 1
		a1 = 1
	if b > 0 and b1 == 0:
		ans = ans + 1
		b = b - 1
		b1 = 1
	if c > 0 and c1 == 0:
		ans = ans + 1
		c = c - 1
		c1 = 1
	if (a > 0 and b > 0) and ab1 == 0:
		ans = ans + 1
		a = a - 1
		b = b - 1
		ab1 = 1
	if (b > 0 and c > 0) and bc1 == 0:
		ans = ans + 1
		b = b - 1
		c = c - 1
		bc1 = 1
	if (a > 0 and c > 0) and ca1 == 0:
		ans = ans + 1
		a = a - 1
		c = c - 1
		ca1 = 1
	if (a > 0 and b > 0 and (c > 0)) and abc1 == 0:
		ans = ans + 1
		(a, b, c) = (0, 0, 0)
		abc1 = 1
	print(ans)


import itertools
c = int(input())
while c:
	data = sorted([int(a) for a in input().split()], reverse=True)
	stuff = [0, 1, 2]
	ff = 0
	for qc in range(1, len(stuff) + 1):
		for subset in itertools.combinations(stuff, qc):
			temp = data
			flag = True
			for i in subset:
				if temp[i] > 0:
					temp[i] -= 1
				else:
					flag = False
					break
			if flag:
				data = temp
				ff += 1
	print(ff)
	c -= 1


from itertools import combinations
food_map = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0), (1, 0, 1), (0, 1, 1), (1, 1, 1)]
pool = [i for i in range(7)]
t = int(input())
for _ in range(t):
	(a, b, c) = tuple(map(int, input().split()))
	flag = False
	for visitors in range(7, 0, -1):
		for comb in combinations(pool, visitors):
			need_a = need_b = need_c = 0
			for person in comb:
				need_a += food_map[person][0]
				need_b += food_map[person][1]
				need_c += food_map[person][2]
			if need_a <= a and need_b <= b and (need_c <= c):
				print(visitors)
				flag = True
				break
		if flag:
			break
	if not flag:
		print(0)


t = int(input())
while t:
	t -= 1
	ans = 0
	(a, b, c) = map(int, input().split())
	if a:
		ans += 1
		a -= 1
	if b:
		ans += 1
		b -= 1
	if c:
		ans += 1
		c -= 1
	if a == 1 and b == 1 and (c > 1):
		a = 0
		b = 0
		c -= 2
		ans += 2
	else:
		if a and b:
			ans += 1
			a -= 1
			b -= 1
		if c and b:
			ans += 1
			c -= 1
			b -= 1
		if c and a:
			ans += 1
			c -= 1
			a -= 1
	if c and a and b:
		ans += 1
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		count = 0
		T = [0 for _ in range(3)]
		(T[0], T[1], T[2]) = map(int, list(input().split()))
		if T[0] > 0:
			count += 1
			T[0] -= 1
		if T[1] > 0:
			count += 1
			T[1] -= 1
		if T[2] > 0:
			count += 1
			T[2] -= 1
		T = sorted(T, reverse=True)
		if T[0] > 0 and T[1] > 0:
			count += 1
			(T[0], T[1]) = (T[0] - 1, T[1] - 1)
		if T[0] > 0 and T[2] > 0:
			count += 1
			(T[0], T[2]) = (T[0] - 1, T[2] - 1)
		if T[1] > 0 and T[2] > 0:
			count += 1
			(T[1], T[2]) = (T[1] - 1, T[2] - 1)
		if min(T) != 0:
			count += 1
		print(count)
main()


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	l = []
	l.append(x)
	l.append(y)
	l.append(z)
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		c -= 1
		ans += 1
	if c > 0 and b > 0:
		ans += 1
		c -= 1
		b -= 1
	if a > 0 and c > 0:
		ans += 1
		a -= 1
		c -= 1
	if b > 0 and a > 0:
		ans += 1
		a -= 1
		b -= 1
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


combinations = [['a', 'b', 'c', 'ba', 'bc', 'ac', 'abc'], ['a', 'b', 'c', 'ab', 'ac', 'bc', 'abc'], ['a', 'b', 'c', 'ca', 'cb', 'ab', 'abc']]
values = ['a', 'b', 'c']
tests = int(input())
for x in range(tests):
	i = 0
	food = dict(zip(values, map(int, input().split())))
	start = max(food, key=food.get)
	if start == 'a':
		i = 1
	elif start == 'c':
		i = 2
	customers = 0
	for comb in combinations[i]:
		catchVal = 0
		for k in comb:
			if not food[k]:
				catchVal = k
				break
		if not catchVal:
			customers += 1
			for km in comb:
				food[km] -= 1
	print(customers)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(a, b, c) = sorted(map(int, input().split()))
	if a >= 4:
		ans = 7
	elif a == 3:
		ans = 6
	elif a == 2:
		if c > 2:
			ans = 5
		else:
			ans = 4
	elif a == 1:
		if b > 1:
			ans = 4
		else:
			ans = 3
	elif b > 1:
		ans = 3
	elif b == 1:
		ans = 2
	elif c > 0:
		ans = 1
	else:
		ans = 0
	print(ans)


t = int(input())
for _ in range(t):
	a = sorted(map(int, input().split()))
	ans = 0
	for i in range(3):
		if a[i] > 0:
			a[i] -= 1
			ans += 1
	a = a[::-1]
	for i in range(3):
		for j in range(i):
			if a[i] > 0 and a[j] > 0:
				a[i] -= 1
				a[j] -= 1
				ans += 1
	if min(a) > 0:
		ans += 1
	print(ans)


N = int(input())
S = [list(map(int, input().split())) for i in range(N)]
for i in range(N):
	(a, b, c) = S[i]
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
		continue
	if a >= 3 and b >= 3 and (c >= 3):
		print(6)
		continue
	if a == 0 and b == 0 and (c == 0):
		print(0)
		continue
	if a == 0 and b == 0 or (b == 0 and c == 0) or (c == 0 and a == 0):
		print(1)
		continue
	if a == 0:
		if b > 1 and c > 1:
			print(3)
			continue
		else:
			print(2)
			continue
	if b == 0:
		if a > 1 and c > 1:
			print(3)
			continue
		else:
			print(2)
			continue
	if c == 0:
		if a > 1 and b > 1:
			print(3)
			continue
		else:
			print(2)
			continue
	if a == 1:
		if b > 1 and c > 1:
			print(4)
			continue
		else:
			print(3)
			continue
	if b == 1:
		if a > 1 and c > 1:
			print(4)
			continue
		else:
			print(3)
			continue
	if c == 1:
		if a > 1 and b > 1:
			print(4)
			continue
		else:
			print(3)
			continue
	if a == 2:
		if b > 2 or c > 2:
			print(5)
			continue
		else:
			print(4)
			continue
	if b == 2:
		if a > 2 or c > 2:
			print(5)
			continue
		else:
			print(4)
			continue
	if c == 2:
		if a > 2 or b > 2:
			print(5)
			continue
		else:
			print(4)
			continue


import itertools

def max_visitors(a, b, c):
	best = 0
	sets = [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	permutations = list(itertools.permutations(sets))
	for perm in permutations:
		i = 0
		(a_, b_, c_) = (a, b, c)
		while i < 7 and (a_ > 0 or perm[i][0] == 0) and (b_ > 0 or perm[i][1] == 0) and (c_ > 0 or perm[i][2] == 0):
			a_ -= perm[i][0]
			b_ -= perm[i][1]
			c_ -= perm[i][2]
			i += 1
		best = max(best, i)
	return best
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	print(max_visitors(a, b, c))


n = int(input())
for _ in range(n):
	count = 0
	List = list(map(int, input().split()))
	if List[0] > 0:
		count = count + 1
		List[0] = List[0] - 1
	if List[1] > 0:
		count = count + 1
		List[1] = List[1] - 1
	if List[2] > 0:
		List[2] = List[2] - 1
		count = count + 1
	List.sort()
	if List[2] > 0 and List[1] > 0:
		count += 1
		List[2] -= 1
		List[1] -= 1
	if List[2] > 0 and List[0] > 0:
		count += 1
		List[2] -= 1
		List[0] -= 1
	if List[0] > 0 and List[1] > 0:
		count += 1
		List[0] -= 1
		List[1] -= 1
	if List[0] > 0 and List[1] > 0 and (List[2] > 0):
		count += 1
	print(count)


T = int(input())
while T > 0:
	q = 0
	x = [int(x) for x in input().split()]
	x.sort(reverse=True)
	a = int(x[0])
	b = int(x[1])
	c = int(x[2])
	if a:
		a = a - 1
		q = q + 1
	if b:
		b = b - 1
		q = q + 1
	if c:
		c = c - 1
		q = q + 1
	if a and b:
		a = a - 1
		b = b - 1
		q = q + 1
	if a and c:
		a = a - 1
		c = c - 1
		q = q + 1
	if b and c:
		b = b - 1
		c = c - 1
		q = q + 1
	if a and b and c:
		q = q + 1
	print(q)
	T = T - 1


for t in range(int(input())):
	data = list(map(int, input().split()))
	data.sort()
	(a, b, c) = data
	visitor = 0
	if any([a, b, c]):
		if a:
			a -= 1
			visitor += 1
		if b:
			b -= 1
			visitor += 1
		if c:
			c -= 1
			visitor += 1
		if b and c:
			b -= 1
			c -= 1
			visitor += 1
		if a and c:
			a -= 1
			c -= 1
			visitor += 1
		if a and b:
			a -= 1
			b -= 1
			visitor += 1
		if a and b and c:
			visitor += 1
	else:
		visitor = 0
	print(visitor)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	cnt = 0
	if a > 0:
		cnt += 1
		a -= 1
	if b > 0:
		cnt += 1
		b -= 1
	if c > 0:
		cnt += 1
		c -= 1
	l = [a, b, c]
	d = max(l)
	l.pop(l.index(d))
	e = max(l)
	l.pop(l.index(e))
	f = max(l)
	if d > 0 and e > 0:
		cnt += 1
		d -= 1
		e -= 1
	if d > 0 and f > 0:
		cnt += 1
		d -= 1
		f -= 1
	if e > 0 and f > 0:
		cnt += 1
		e -= 1
		f -= 1
	if e > 0 and f > 0 and (d > 0):
		cnt += 1
	print(cnt)


t = int(input())
while t > 0:
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	tot = 0
	if a[0] > 0:
		tot = tot + 1
		a[0] = a[0] - 1
	if a[1] > 0:
		tot = tot + 1
		a[1] = a[1] - 1
	if a[2] > 0:
		tot = tot + 1
		a[2] = a[2] - 1
	if (a[0] > 0) & (a[1] > 0):
		tot = tot + 1
		a[0] = a[0] - 1
		a[1] = a[1] - 1
	if (a[0] > 0) & (a[2] > 0):
		tot = tot + 1
		a[0] = a[0] - 1
		a[2] = a[2] - 1
	if (a[1] > 0) & (a[2] > 0):
		tot = tot + 1
		a[1] = a[1] - 1
		a[2] = a[2] - 1
	if (a[1] > 0) & (a[2] > 0) & (a[0] > 0):
		tot = tot + 1
	print(tot)
	a.clear()
	t = t - 1


t = int(input())
for i in range(t):
	mass = [int(x) for x in input().split()]
	mass.sort(reverse=True)
	(a, b, c) = mass
	answer = 0
	if a > 0:
		a -= 1
		answer += 1
	if b > 0:
		b -= 1
		answer += 1
	if c > 0:
		c -= 1
		answer += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		answer += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		answer += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		answer += 1
	if a > 0 and b > 0 and (c > 0):
		answer += 1
	print(answer)


def go():
	v = list(map(int, input().split()))
	res = sum((1 if x > 0 else 0 for x in v))
	v = sorted([max(vv - 1, 0) for vv in v], reverse=True)
	for i in range(3):
		for j in range(i + 1, 3):
			if v[i] > 0 and v[j] > 0:
				res += 1
				v[i] -= 1
				v[j] -= 1
	if all(v):
		res += 1
	return res
t = int(input())
for _ in range(t):
	print(go())


from itertools import permutations as perm

def fn(a, b, c):
	if a < 2 and b < 2 and (c < 2):
		return a + b + c
	if a > 3 and b > 3 and (c > 3):
		return 7
	a = min(a, 3)
	b = min(b, 3)
	c = min(c, 3)
	total = 0
	if a > 0:
		a -= 1
		total += 1
	if b > 0:
		b -= 1
		total += 1
	if c > 0:
		c -= 1
		total += 1
	zeros = 0
	for e in [a, b, c]:
		if e == 0:
			zeros += 1
	if zeros == 1:
		return total + 1
	elif zeros == 2:
		return total
	return total + (a + b + c) // 2
for i in range(int(input())):
	arr = map(int, input().split())
	res = 0
	for p in perm(arr):
		res = max(0, fn(*p))
	print(res)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	cnt = 0
	if arr[0] > 0:
		arr[0] = arr[0] - 1
		cnt += 1
	if arr[1] > 0:
		arr[1] = arr[1] - 1
		cnt += 1
	if arr[2] > 0:
		cnt += 1
		arr[2] = arr[2] - 1
	m = max(arr)
	ind = arr.index(m)
	arr.pop(ind)
	c = m
	if arr[0] != 0:
		if arr[0] <= c:
			cnt += 1
			arr[0] = arr[0] - 1
			m = m - 1
	if arr[1] != 0 and m != 0:
		if arr[1] <= c:
			cnt += 1
			arr[1] = arr[1] - 1
			m = m - 1
	if arr[0] > 0 and arr[1] > 0:
		cnt += 1
		arr[0] = arr[0] - 1
		arr[1] = arr[1] - 1
	if arr[0] > 0 and arr[1] > 0 and (m > 0):
		cnt += 1
	print(cnt)


def check(l):
	count = 0
	if l[0] >= 4:
		return 7
	else:
		for i in range(3):
			if l[i] > 0:
				count += 1
				l[i] -= 1
		if l[0] > 0:
			count += 1
			l[0] -= 1
			l[2] -= 1
		if l[1] > 0 and l[2] > 0:
			count += 1
			l[1] -= 1
			l[2] -= 1
		if l[0] > 0 and l[1] > 0:
			count += 1
		return count
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	print(check(l))


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(A, B, C):
	d = [A, B, C]
	ans = 0
	for i in combinations(range(3), r=1):
		i = i[0]
		if d[i] >= 1:
			ans += 1
			d[i] -= 1
	d.sort(reverse=True)
	for i in combinations(range(3), r=2):
		(i, j) = i
		if d[i] >= 1 and d[j] >= 1:
			ans += 1
			d[i] -= 1
			d[j] -= 1
	if d[0] > 0 and d[1] > 0 and (d[2] > 0):
		ans += 1
	return ans

def main():
	T = read_int()
	for _ in range(T):
		(A, B, C) = read_int_n()
		print(slv(A, B, C))
main()


n = int(input())
for _ in range(n):
	(a, b, c) = map(int, input().split())
	if a >= 4 and b >= 4 and (c >= 4):
		print(7)
	else:
		res = 0
		if a:
			res += 1
			a -= 1
		if b:
			res += 1
			b -= 1
		if c:
			res += 1
			c -= 1
		k = max(a, b, c)
		if k == a:
			if a and b:
				res += 1
				a -= 1
				b -= 1
			if a and c:
				res += 1
				a -= 1
				c -= 1
			if b and c:
				res += 1
				b -= 1
				c -= 1
		elif k == b:
			if a and b:
				res += 1
				a -= 1
				b -= 1
			if b and c:
				res += 1
				b -= 1
				c -= 1
			if a and c:
				res += 1
				a -= 1
				c -= 1
		elif k == c:
			if a and c:
				res += 1
				a -= 1
				c -= 1
			if b and c:
				res += 1
				b -= 1
				c -= 1
			if a and b:
				res += 1
				b -= 1
				a -= 1
		if a and b and c:
			res += 1
			a -= 1
			b -= 1
			c -= 1
		print(res)


a = int(input())
for i in range(0, a):
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	counter = 0
	for i in range(0, len(arr)):
		if arr[i] >= 1:
			counter = counter + 1
			arr[i] = arr[i] - 1
	if arr[1] >= 1:
		counter = counter + 1
		arr[1] = arr[1] - 1
		arr[0] = arr[0] - 1
	if arr[0] >= 1 and arr[2] >= 1:
		counter = counter + 1
		arr[0] = arr[0] - 1
		arr[2] = arr[2] - 1
	if arr[1] >= 1 and arr[2] >= 1:
		counter = counter + 1
		arr[1] = arr[1] - 1
		arr[2] = arr[2] - 1
	if arr[0] >= 1 and arr[1] >= 1 and (arr[2] >= 1):
		counter = counter + 1
	print(counter)


def f(a, b, c):
	l = [a, b, c]
	l = sorted(l)
	plans = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
	ans = 0
	for i in range(7):
		after = [l[j] - plans[i][j] for j in range(3)]
		if after[0] < 0 or after[1] < 0 or after[2] < 0:
			pass
		else:
			l = after
			ans += 1
	return ans
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	ans = f(a, b, c)
	print(ans)


t = int(input())
while t:
	t -= 1
	f = set()
	s = 0
	a = list(map(int, input().split()))
	for i in range(3):
		if a[i] != 0:
			s += 1
			a[i] -= 1
	a.sort(reverse=True)
	if a[0] != 0 and a[1] != 0:
		s += 1
		a[0] -= 1
		a[1] -= 1
	if a[0] != 0 and a[2] != 0:
		s += 1
		a[0] -= 1
		a[2] -= 1
	if a[1] != 0 and a[2] != 0:
		s += 1
		a[1] -= 1
		a[2] -= 1
	if min(a) != 0:
		s += 1
	print(s)


t = int(input())
while t > 0:
	(a, b, k) = input().split()
	d = int(a)
	c = int(b)
	p = int(k)
	max1 = 0
	if d == 0 and k == 0 and (p == 0):
		max1 = 0
	elif d >= 1 and p == 0 and (c == 0) or (d == 0 and p >= 1 and (c == 0)) or (d == 0 and p == 0 and (c >= 1)):
		max1 = 1
	elif d == 0 and p == 1 and (c >= 1) or (d == 1 and p == 0 and (c >= 1)) or (d == 1 and p >= 1 and (c == 0)) or (d == 0 and p >= 1 and (c == 1)) or (d >= 1 and p == 1 and (c == 0)) or (d >= 1 and p == 0 and (c == 1)):
		max1 = 2
	elif d == 1 and p == 1 and (c >= 1) or (d == 1 and c == 1 and (p >= 1)) or (c == 1 and p == 1 and (d >= 1)) or (d == 0 and p >= 2 and (c >= 2)) or (p == 0 and d >= 2 and (c >= 2)) or (c == 0 and p >= 2 and (d >= 2)):
		max1 = 3
	elif d == 1 and p >= 2 and (c >= 2) or (p == 1 and d >= 2 and (c >= 2)) or (c == 1 and p >= 2 and (d >= 2)) or (d == 2 and p == 2 and (c == 2)):
		max1 = 4
	elif d == 2 and p == 2 and (c >= 3) or (c == 2 and p == 2 and (d >= 3)) or (d == 2 and c == 2 and (p >= 3)) or (d >= 3 and p >= 3 and (c == 2)) or (d >= 3 and c >= 3 and (p == 2)) or (c >= 3 and p >= 3 and (d == 2)):
		max1 = 5
	elif d == 3 and p >= 3 and (c >= 3) or (p == 3 and d >= 3 and (c >= 3)) or (c == 3 and p >= 3 and (d >= 3)):
		max1 = 6
	elif d >= 4 and p >= 4 and (c >= 4):
		max1 = 7
	print(max1)
	t = t - 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	ans = [0] * 7
	l.sort()
	if l[0] >= 4:
		print(7)
	elif l[0] == 0:
		if l[1] == 1 and l[2] >= 1:
			print(2)
		elif l[1] == 0 and l[2] >= 1:
			print(1)
		elif l[1] >= 2 and l[2] >= 2:
			print(3)
		else:
			print(0)
	elif l[0] == 1:
		if l[1] == 1 and l[2] >= 1:
			print(3)
		else:
			print(4)
	elif l[0] == 2:
		if l[1] == 2 and l[2] == 2:
			print(4)
		else:
			print(5)
	elif l[0] == 3:
		print(6)


n = int(input())
ans = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0], [1, 1, 1]]
for x in range(n):
	l = list(map(int, input().split()))
	l.sort()
	cnt = 0
	for y in ans:
		if l[0] - y[0] >= 0 and l[1] - y[1] >= 0 and (l[2] - y[2] >= 0):
			l[0] -= y[0]
			l[1] -= y[1]
			l[2] -= y[2]
			cnt += 1
		else:
			continue
	print(cnt)


for _ in range(int(input())):
	array = list(map(int, input().split()))
	a = max(array)
	c = min(array)
	b = sum(array) - (a + c)
	count = 0
	if a == b == c == 0:
		print(0)
	else:
		if a > 0:
			a -= 1
			count += 1
		if b > 0:
			b -= 1
			count += 1
		if a > 0 and b > 0:
			a -= 1
			b -= 1
			count += 1
		if a > 0 and c > 0:
			a -= 1
			c -= 1
			count += 1
		if b > 0 and c > 0:
			b -= 1
			c -= 1
			count += 1
		if a > 0 and b > 0 and (c > 0):
			count += 1
			a -= 1
			b -= 1
			c -= 1
		if c > 0:
			c -= 1
			count += 1
		print(count)


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


t = int(input())
for _ in range(t):
	abc = list(map(int, input().split()))
	abc.sort()
	ans = 0
	for pat in ((1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)):
		for i in range(3):
			if abc[i] < pat[i]:
				break
		else:
			ans += 1
			for i in range(3):
				abc[i] -= pat[i]
	print(ans)


def calcular(a, b, c):
	max = 0
	if a > 0:
		a -= 1
		max += 1
	if b > 0:
		b -= 1
		max += 1
	if c > 0:
		c -= 1
		max += 1
	if a > 0 and b > 0:
		a -= 1
		b -= 1
		max += 1
	if a > 0 and c > 0:
		a -= 1
		c -= 1
		max += 1
	if b > 0 and c > 0:
		b -= 1
		c -= 1
		max += 1
	if a > 0 and b > 0 and (c > 0):
		max += 1
	return max
t = int(input())
for n in range(t):
	(a, b, c) = [int(i) for i in input().split()]
	max = 0
	pos1 = calcular(a, b, c)
	max = pos1
	pos2 = calcular(a, c, b)
	if pos2 > max:
		max = pos2
	pos3 = calcular(b, a, c)
	if pos3 > max:
		max = pos3
	pos4 = calcular(c, b, a)
	if pos4 > max:
		max = pos4
	pos5 = calcular(c, a, b)
	if pos5 > max:
		max = pos5
	print(max)


t = int(input())
for test in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	if a > 0:
		ans += 1
		a -= 1
	if b > 0:
		ans += 1
		b -= 1
	if c > 0:
		ans += 1
		c -= 1
	mn = min(a, b, c)
	mx = max(a, b, c)
	if mn == 0:
		t1 = max(a, b)
		t2 = max(b, c)
		t3 = max(a, c)
		if t1 > 0 and t2 > 0 and (t3 > 0):
			ans += 1
		a = 0
		b = 0
		c = 0
	if mn == 1:
		if mx == 1:
			ans += 1
		else:
			ans += 2
		a = 0
		b = 0
		c = 0
	if mn >= 2:
		ans += 3
		a -= 2
		b -= 2
		c -= 2
	if a > 0 and b > 0 and (c > 0):
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	m = []
	foo = 0
	a = [[1, 1, 1, 3], [1, 1, 2, 3], [1, 2, 2, 4], [2, 2, 2, 4], [2, 2, 3, 5], [2, 3, 3, 5], [3, 3, 3, 6], [4, 4, 4, 7]]
	l.sort()
	for i in range(8):
		if l[0] - a[i][0] > -1 and l[1] - a[i][1] > -1 and (l[2] - a[i][2] > -1):
			m.append(a[i][-1])
	if len(m) > 0:
		print(m[-1])
	else:
		l.reverse()
		if l.count(0) == 1:
			if min(l[0], l[1]) >= 2:
				print(3)
			else:
				print(2)
		elif l.count(0) == 2:
			print(1)
		else:
			print(0)