For the human eye, primary colours are red, green, and blue. 

Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta.

You have X, Y, and Z drops of red, green, and blue colours respectively. Find the maximum total number of distinct colours (both primary and secondary) you can have at any particular moment.

Note: You cannot mix a secondary colour with a primary or another secondary colour to get a new type of colour.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of three space separated integers X, Y,  and Z, the number of drops of red, green, and blue colours respectively. 

------ Output Format ------ 

For each test case, output on a new line the maximum total number of colours (both primary and secondary) you can have using the given primary colours.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$0 ≤ X, Y, Z≤ 100$

----- Sample Input 1 ------ 
4
1 0 1
3 3 0
1 1 1
0 0 0

----- Sample Output 1 ------ 
2
3
3
0
----- explanation 1 ------ 
Test case $1$: We have $1$ drop each of red and blue colour. If we mix these colours, we will have magenta but no red or blue. Thus, to maximize the total number of colours, it is better that we keep the red and blue colours as it is. The maximum number of colours we can have is $2$.

Test case $2$: We have $3$ drops each of red and green colour. We can use $1$ drop each of red and green to have yellow. We still have $2$ drops each of red and green left. Thus, we have $3$ different types of colours now.

Test case $3$: If we mix any two colours, we will loose two colours and get only one colour in return. Thus, it is best to keep all colours as it is and keep $3$ different varieties of colours.

Test case $4$: There are no types of colours available.

Source: codechef | Difficulty: MEDIUM
Tags: Bit manipulation

Mathematics

Ad-hoc


Solutions:
test = int(input())
while test > 0:
	test = test - 1
	(X, Y, Z) = map(int, input().split())
	list1 = [X, Y, Z]
	ans = 0
	if list1[0] > 0:
		ans += 1
		list1[0] -= 1
	if list1[1] > 0:
		ans += 1
		list1[1] -= 1
	if list1[2] > 0:
		ans += 1
		list1[2] -= 1
	list1.sort()
	list1.reverse()
	if list1[0] > 0 and list1[1] > 0:
		ans += 1
		list1[0] -= 1
		list1[1] -= 1
	if list1[0] > 0 and list1[2] > 0:
		ans += 1
		list1[0] -= 1
		list1[2] -= 1
	if list1[1] > 0 and list1[2] > 0:
		ans += 1
		list1[1] -= 1
		list1[2] -= 1
	print(ans)


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


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	n = 0
	if x > 0:
		n += 1
		x -= 1
	if y > 0:
		n += 1
		y -= 1
	if z > 0:
		n += 1
		z -= 1
	(x, y, z) = sorted([x, y, z], reverse=True)
	if x > 0 and y > 0:
		n += 1
		x -= 1
		y -= 1
	if z > 0 and y > 0:
		n += 1
		z -= 1
		y -= 1
	if x > 0 and z > 0:
		n += 1
		x -= 1
		z -= 1
	print(n)


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


x = int(input())
g = []
for iir in range(0, x):
	op = str(input())
	kkr = op.split(' ')
	uure = []
	for bbv in kkr:
		uure.append(int(bbv))
	g.append(uure)
for nnx in g:
	if nnx[0] == 0 and nnx[1] == 0 and (nnx[2] == 0):
		print(0)
	else:
		nnx.sort(reverse=True)
		a = nnx[0]
		b = nnx[1]
		c = nnx[2]
		ansd = 0
		if a > 1 and b > 1:
			ansd += 1
			a -= 1
			b -= 1
		if b > 1 and c > 1:
			ansd += 1
			b -= 1
			c -= 1
		if c > 1 and a > 1:
			ansd += 1
			c -= 1
			a -= 1
		prt = [a, b, c]
		for iinc in prt:
			if iinc != 0:
				ansd += 1
		print(ansd)


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


n = int(input())
d = []
for i in range(n):
	l = [int(x) for x in input().split()]
	ans = 3 - l.count(0)
	l.sort()
	if l[0] >= 3:
		print(6)
	elif l[0] == 2:
		if l[2] >= 3:
			ans = 5
		else:
			ans = 4
		print(ans)
	elif l[1] <= 1:
		print(ans)
	else:
		print(ans + 1)


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


n = int(input())
for p in range(0, n):
	arr = [int(i) for i in input().split()]
	arr.sort()
	x = arr[0]
	y = arr[1]
	z = arr[2]
	ans = 0
	for i in range(3):
		if arr[i] >= 1:
			ans += 1
	if x == 2:
		if z >= 3:
			print(ans + 2)
		else:
			print(ans + 1)
	elif x >= 3:
		print(ans + 3)
	elif y <= 1:
		print(ans)
	else:
		print(ans + 1)


T = int(input())
for _ in range(T):
	list1 = list(map(int, input().split(' ')))
	list1.sort(reverse=True)
	(X, Y, Z) = (list1[0], list1[1], list1[2])
	x = X - 1 if X > 1 else 0
	y = Y - 1 if Y > 1 else 0
	z = Z - 1 if Z > 1 else 0
	total = min(X, 1) + min(Y, 1) + min(Z, 1)
	if x and y:
		total += 1
		x -= 1
		y -= 1
	if x and z:
		total += 1
		x -= 1
		z -= 1
	if z and y:
		total += 1
	print(total)


for i in range(0, int(input())):
	l = list(map(int, input().split()))
	a = 0
	for j in range(0, 3):
		if l[j] > 0:
			a = a + 1
			l[j] = l[j] - 1
		else:
			continue
	n = 0
	x = l[0]
	y = l[1]
	z = l[2]
	(x, y, z) = sorted([x, y, z], reverse=True)
	if x > 0 and y > 0:
		n += 1
		x -= 1
		y -= 1
	if y > 0 and z > 0:
		n += 1
		z -= 1
		y -= 1
	if x > 0 and z > 0:
		n += 1
		x -= 1
		z -= 1
	print(int(a + n))


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	a.sort()
	b = []
	for i in a:
		if i:
			b.append(i)
	ans = len(b)
	if len(b) == 2:
		if b[0] > 1:
			ans += 1
	elif len(b) == 3:
		if b[0] > 1 and b[2] > 1:
			b[0] -= 1
			b[2] -= 1
			ans += 1
		if b[1] > 1 and b[2] > 1:
			b[1] -= 1
			b[2] -= 1
			ans += 1
		if b[1] > 1 and b[0] > 1:
			ans += 1
	print(ans)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(b, g, r) = sorted(map(int, input().split()))
	if b == 0:
		print(3 if g > 1 else 2 if g > 0 else 1 if r > 0 else 0)
	elif b == 1:
		print(4 if g > 1 else 3)
	elif b == 2:
		print(5 if r > 2 else 4)
	else:
		print(6)


vojj = int(input())
for vishnesh in range(vojj):
	(r, g, b) = map(int, input().split())
	c = 0
	if r > 0:
		r = r - 1
		c = c + 1
	if g > 0:
		g = g - 1
		c = c + 1
	if b > 0:
		b = b - 1
		c = c + 1
	a = [r, g, b]
	a.sort()
	a = a[::-1]
	(r, g, b) = a
	if r > 0 and g > 0:
		r = r - 1
		g = g - 1
		c = c + 1
	if b > 0 and g > 0:
		g = g - 1
		b = b - 1
		c = c + 1
	if r > 0 and b > 0:
		r = r - 1
		b = b - 1
		c = c + 1
	print(c)


for i in range(int(input())):
	lst = [int(a) for a in input().split()]
	lst.sort(reverse=True)
	answer = 0
	if lst == [0, 0, 0]:
		print(0)
	else:
		x = 0
		for i in range(3):
			if lst[i - x] == 0:
				lst.remove(0)
				x += 1
			else:
				lst[i] -= 1
				answer += 1
		for i in range(len(lst)):
			for j in range(i + 1, min(len(lst), i + lst[i] + 1)):
				if lst[i] == 0:
					break
				elif lst[j] > 0:
					lst[j] -= 1
					lst[i] -= 1
					answer += 1
		print(answer)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split(' '))
	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 * y * z == 0 and (x, y, z).count(0) == 1:
		c += 1
	elif (x, y, z).count(0) == 2:
		c += 0
	elif (x, y, z).count(0) == 0:
		if (x, y, z).count(1) == 0:
			c += 3
		elif (x, y, z).count(1) in (1, 2):
			c += 2
		elif (x, y, z).count(1) == 3:
			c += 1
	print(c)


for _ in range(int(input())):
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	(X, Y, Z) = A
	colors = 0
	if X > 1 and Y > 1:
		colors += 1
		X -= 1
		Y -= 1
	if Y > 1 and Z > 1:
		colors += 1
		Y -= 1
		Z -= 1
	if Z > 1 and X > 1:
		colors += 1
		Z -= 1
		X -= 1
	colors += X > 0
	colors += Y > 0
	colors += Z > 0
	print(colors)


for tc in range(int(input())):
	colors = [*map(int, input().split())]
	colors.sort(reverse=True)
	cnt = 0
	for i in range(3):
		if colors[i] > 0:
			colors[i] -= 1
			cnt += 1
	combinations = [(0, 1), (1, 2), (0, 2)]
	for (i, j) in combinations:
		if colors[i] > 0 and colors[j] > 0:
			colors[i] -= 1
			colors[j] -= 1
			cnt += 1
	print(cnt)


def check(a, b, output):
	if a > 0 and b > 0:
		return (a - 1, b - 1, output + 1)
	return (a, b, output)
n = int(input())
for i in range(n):
	row = sorted(map(int, input().split()), reverse=True)
	colors = []
	output = 0
	for i in row:
		if i > 0:
			colors.append(i - 1)
			output += 1
		else:
			colors.append(0)
	(r, g, b) = colors
	(r, g, output) = check(r, g, output)
	(r, b, output) = check(r, b, output)
	(g, b, output) = check(g, b, output)
	print(output)


def check(a, b, output):
	if a > 0 and b > 0:
		return (a - 1, b - 1, output + 1)
	return (a, b, output)
n = int(input())
for i in range(n):
	colors = list(map(int, input().split()))
	output = len([i for i in colors if i > 0])
	(r, g, b) = sorted([i - 1 for i in colors], reverse=True)
	(r, g, output) = check(r, g, output)
	(r, b, output) = check(r, b, output)
	(g, b, output) = check(g, b, output)
	print(output)


import math
for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	s = 0
	total = sum((i > 0 for i in [r, g, b]))
	select1 = sum((i > 1 for i in [r, g, b]))
	select2 = sum((i > 2 for i in [r, g, b]))
	if select2 == 3:
		print(total + 3)
	elif select2 == 2:
		if select1 == 3:
			print(total + 2)
		else:
			print(total + 1)
	elif select2 == 1:
		if select1 == 3:
			print(total + 2)
		elif select1 == 2:
			print(total + 1)
		else:
			print(total)
	elif select1 > 1:
		print(total + 1)
	else:
		print(total)


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


def check_positions(sorted_array, first_pos, second_pos):
	try:
		if sorted_array[first_pos] > 1 and sorted_array[second_pos] > 1:
			sorted_array[first_pos] -= 1
			sorted_array[second_pos] -= 1
			return 1
	except IndexError:
		pass
	return 0

def find_max(r, g, b):
	sorted_array = [r, g, b]
	sorted_array.sort(reverse=True)
	max_colours = 0
	for position in (0, 1):
		next_po = position + 1
		max_colours += check_positions(sorted_array, position, next_po)
		second_next_pos = next_po + 1
		max_colours += check_positions(sorted_array, position, second_next_pos)
	for colour in sorted_array:
		max_colours += min(1, colour)
	return max_colours
t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	print(find_max(r, g, b))


def find_max(r, g, b):
	sorted_array = [r, g, b]
	sorted_array.sort(reverse=True)
	max_colours = 0
	for position in (0, 1):
		next_po = position + 1
		if sorted_array[next_po] > 1 and sorted_array[position] > 1:
			max_colours += 1
			sorted_array[next_po] -= 1
			sorted_array[position] -= 1
		second_next_pos = next_po + 1
		if second_next_pos < 3:
			if sorted_array[second_next_pos] > 1 and sorted_array[position] > 1:
				max_colours += 1
				sorted_array[position] -= 1
				sorted_array[second_next_pos] -= 1
	for colour in sorted_array:
		max_colours += min(1, colour)
	colours_possible_with_just_individual_colours = min(1, r) + min(1, g) + min(1, b)
	return max(max_colours, colours_possible_with_just_individual_colours)
t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	print(find_max(r, g, b))


import math
import itertools
number_of_test_cases = int(input())
for i in range(number_of_test_cases):
	colors = [*map(int, input().split())]
	colors.sort(reverse=True)
	cnt = 0
	for i in range(3):
		if colors[i] > 0:
			colors[i] -= 1
			cnt += 1
	combinations = [(0, 1), (1, 2), (0, 2)]
	for (i, j) in combinations:
		if colors[i] > 0 and colors[j] > 0:
			colors[i] -= 1
			colors[j] -= 1
			cnt += 1
	print(cnt)


import math
import itertools
number_of_test_cases = int(input())
for i in range(number_of_test_cases):
	colors = [*map(int, input().split())]
	non_zero_colors = [each for each in colors if each]
	pair_possiblity_count = [min(2, x - 1 if x else 0) for x in colors]
	pair_possiblity_dict = {'r': pair_possiblity_count[0], 'g': pair_possiblity_count[1], 'b': pair_possiblity_count[2]}
	pair_possiblity_dict = dict(zip('rgb', sorted(pair_possiblity_count, reverse=True)))
	combinations = [*itertools.combinations(list(pair_possiblity_dict.keys()), 2)]
	count = 0
	for combination in combinations:
		if pair_possiblity_dict[combination[0]] and pair_possiblity_dict[combination[1]]:
			pair_possiblity_dict[combination[0]] -= 1
			pair_possiblity_dict[combination[1]] -= 1
			count += 1
	print(count + len(non_zero_colors))


for i in range(0, int(input())):
	li = list(map(int, input().strip().split()))
	li.sort(reverse=True)
	cnt = 0
	for i in range(0, len(li)):
		if li[i] > 0:
			li[i] -= 1
			cnt += 1
	for i in range(0, len(li)):
		for j in range(i + 1, len(li)):
			if li[i] > 0 and li[j] > 0:
				li[i] -= 1
				li[j] -= 1
				cnt += 1
	print(cnt)


from math import sqrt, ceil, floor, gcd, log2
import sys
from sys import stdin, stdout
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import combinations, groupby
from time import time
from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	(x, y, z) = map(int, input().split())
	cnt = 0
	if x > 0:
		cnt += 1
		x -= 1
	if y > 0:
		cnt += 1
		y -= 1
	if z > 0:
		cnt += 1
		z -= 1
	arr = [x, y, z]
	arr.sort(reverse=True)
	if arr[0] > 0 and arr[1] > 0:
		cnt += 1
		arr[0] -= 1
		arr[1] -= 1
	if arr[2] > 0 and arr[1] > 0:
		cnt += 1
		arr[2] -= 1
		arr[1] -= 1
	if arr[0] > 0 and arr[2] > 0:
		cnt += 1
		arr[0] -= 1
		arr[2] -= 1
	print(cnt)


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


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	s = 0
	l = []
	if a > 0:
		s += 1
		a -= 1
	if b > 0:
		s += 1
		b -= 1
	if c > 0:
		s += 1
		c -= 1
	(x, p) = (a, a)
	(y, q) = (b, b)
	(z, r) = (c, c)
	(l, m, n) = (0, 0, 0)
	if x > 0 and y > 0:
		l += 1
		x -= 1
		y -= 1
	if y > 0 and z > 0:
		l += 1
		y -= 1
		z -= 1
	if z > 0 and x > 0:
		l += 1
		z -= 1
		x -= 1
	if b > 0 and c > 0:
		m += 1
		b -= 1
		c -= 1
	if c > 0 and a > 0:
		m += 1
		c -= 1
		a -= 1
	if a > 0 and b > 0:
		m += 1
		b -= 1
		a -= 1
	if r > 0 and p > 0:
		r -= 1
		p -= 1
		n += 1
	if p > 0 and q > 0:
		q -= 1
		p -= 1
		n += 1
	if q > 0 and r > 0:
		q -= 1
		r -= 1
		n += 1
	print(max(l, m, n) + s)
	t -= 1


for _ in range(int(input())):
	colors = sorted(list(map(int, input().split())), reverse=True)
	made = 0
	for thing in range(3):
		if colors[thing] > 0:
			colors[thing] -= 1
			made += 1
	for thing in range(3):
		for thingy in range(thing + 1, 3):
			if colors[thing] > 0 and colors[thingy] > 0:
				colors[thing] -= 1
				colors[thingy] -= 1
				made += 1
	print(made)


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


p = int(input())
while p:
	arr = [int(i) for i in input().split()]
	count = 0
	count2 = 0
	arr.sort()
	arr = arr[::-1]
	for i in range(3):
		if arr[i] > 0:
			arr[i] -= 1
			count2 += 1
	for i in range(3):
		for j in range(i + 1, 3):
			if arr[i] > 0 and arr[j] > 0:
				count2 += 1
				arr[i] -= 1
				arr[j] -= 1
	print(count2)
	p -= 1


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


case = int(input())
for _ in range(case):
	arr = list(map(int, input().split(' ')))
	count = 0
	n = 3
	arr.sort()
	if arr[n - 1] > 1 and arr[n - 2] > 1:
		count += 1
		arr[n - 1] -= 1
		arr[n - 2] -= 1
	if arr[n - 1] > 1 and arr[n - 3] > 1:
		count += 1
		arr[n - 1] -= 1
		arr[n - 3] -= 1
	if arr[n - 2] > 1 and arr[n - 3] > 1:
		count += 1
		arr[n - 2] -= 1
		arr[n - 3] -= 1
	if arr[n - 1] > 0:
		count += 1
	if arr[n - 2] > 0:
		count += 1
	if arr[n - 3] > 0:
		count += 1
	print(count)


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


reply = []
for _ in range(int(input())):
	arr = []
	for i in input().split():
		arr.append(int(i))
	arr.sort()
	arr.reverse()
	r = arr[0]
	g = arr[1]
	b = arr[2]
	count = 0
	if r >= 1:
		count += 1
		r -= 1
	if g >= 1:
		count += 1
		g -= 1
	if b >= 1:
		count += 1
		b -= 1
	if r >= 1 and b >= 1:
		count += 1
		r -= 1
		b -= 1
	if b >= 1 and g >= 1:
		count += 1
		g -= 1
		b -= 1
	if r >= 1 and g >= 1:
		count += 1
		r -= 1
		g -= 1
	reply.append(count)
for i in reply:
	print(i)


for _ in range(int(input())):
	(x, y, z) = list(map(int, input().split()))
	li = []
	li.extend((x, y, z))
	li.sort()
	add = 0
	for i in li:
		if i != 0:
			add += 1
	if li[0] >= 3:
		print(add + 3)
	elif li[0] == 2:
		if li[2] >= 3:
			print(add + 2)
		else:
			print(add + 1)
	elif li[1] <= 1:
		print(add)
	else:
		print(add + 1)


for i in range(int(input())):
	c = list(map(int, input().split()))
	c = [x for x in c if x != 0]
	s = len(c)
	for i in range(len(c)):
		if c[i] >= 3:
			c = c[:i] + [3] + c[i + 1:]
	c = [x - 1 for x in c]
	c = [x for x in c if x != 0]
	if sum(c) == 6:
		s += 3
	elif sum(c) == 5:
		s += 2
	elif sum(c) == 4 and 1 in c:
		s += 2
	elif sum(c) <= 4 and sum(c) != 0:
		if len(c) != 1:
			s += 1
	else:
		s += 0
	print(s)


for _ in range(int(input())):
	a = sorted(list(map(int, input().split())))
	add = 0
	for i in a:
		if i != 0:
			add += 1
	if a[0] >= 3:
		print(add + 3)
	elif a[0] == 2:
		if a[2] >= 3:
			print(add + 2)
		else:
			print(add + 1)
	elif a[1] <= 1:
		print(add)
	else:
		print(add + 1)


t = int(input())
for _ in range(t):
	(x, y, z) = map(int, input().split())
	if x > 2 and y > 2 and (z > 2):
		print(6)
	elif x > 2 and y > 1 and (z > 1) or (y > 2 and x > 1 and (z > 1)) or (z > 2 and x > 1 and (y > 1)):
		print(5)
	elif x == 2 and y == 2 and (z == 2):
		print(4)
	elif x > 1 and y > 1 and (z <= 1):
		print(3 + z)
	elif x > 1 and z > 1 and (y <= 1):
		print(3 + y)
	elif y > 1 and z > 1 and (x <= 1):
		print(3 + x)
	else:
		print(int(x >= 1) + int(y >= 1) + int(z >= 1))


T = int(input())
for i in range(T):
	l = []
	s = 0
	(x, y, z) = map(int, input().split())
	l.append(x)
	l.append(y)
	l.append(z)
	for i in range(3):
		if l[i] != 0:
			l[i] -= 1
			s += 1
	l.sort()
	if l[0] >= 2:
		print(s + 3)
	elif l[0] == 1:
		if l[2] >= 2:
			s += 2
		else:
			s += 1
		print(s)
	else:
		if l[1] == 0:
			s
		else:
			s += 1
		print(s)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	temp = [x, y, z]
	res = 0
	for col in range(3):
		if temp[col] >= 1:
			temp[col] -= 1
			res += 1
	temp.sort()
	if temp[0] >= 2:
		res += 3
	elif temp[0] == 1:
		if temp[2] >= 2:
			res += 2
		else:
			res += 1
	elif temp[1] != 0:
		res += 1
	print(res)


t = int(input())
while t > 0:
	(r, g, b) = map(int, input().split())
	res = 0
	l = [r, g, b]
	l.sort()
	r = l[2]
	g = l[1]
	b = l[0]
	if r > 0:
		res += 1
		r -= 1
	if g > 0:
		res += 1
		g -= 1
	if b > 0:
		res += 1
		b -= 1
	if r > 0 and g > 0:
		res += 1
		r -= 1
		g -= 1
	if g > 0 and b > 0:
		res += 1
		g -= 1
		b -= 1
	if b > 0 and r > 0:
		res += 1
	print(res)
	t -= 1


for _ in range(int(input())):
	(X, Y, Z) = map(int, input().split())
	l = [X, Y, Z]
	ways = 0
	for i in range(3):
		if l[i] >= 1:
			l[i] -= 1
			ways += 1
	l.sort()
	if l[0] >= 2:
		ways += 3
	elif l[0] == 1:
		if l[2] >= 2:
			ways += 2
		else:
			ways += 1
	elif l[1] != 0:
		ways += 1
	print(ways)


for _ in range(int(input())):
	li = list(map(int, input().split()))
	zero = 0
	one = 0
	two = 0
	for i in li:
		if i == 0:
			zero += 1
		elif i == 1:
			one += 1
		elif i == 2:
			two += 1
	if zero == 3:
		res = 0
	elif zero == 2:
		res = 1
	elif zero == 1:
		if li[0] == 1 or li[1] == 1 or li[2] == 1:
			res = 2
		else:
			res = 3
	elif one == 1 or two == 3:
		res = 4
	elif one == 2 or one == 3:
		res = 3
	elif two == 1 or two == 2:
		res = 5
	else:
		res = 6
	print(res)


for _ in range(int(input())):
	(x, y, z) = [int(x) for x in input().split()]
	ans = 0
	if x > 0:
		ans += 1
		x -= 1
	if y > 0:
		ans += 1
		y -= 1
	if z > 0:
		ans += 1
		z -= 1
	l1 = [x, y, z]
	l1.sort()
	l1.reverse()
	if l1[0] > 0 and l1[1] > 0:
		ans += 1
		l1[0] -= 1
		l1[1] -= 1
	if l1[0] > 0 and l1[2] > 0:
		ans += 1
		l1[0] -= 1
		l1[2] -= 1
	if l1[1] > 0 and l1[2] > 0:
		ans += 1
		l1[1] -= 1
		l1[2] -= 1
	print(ans)


get_int = lambda : int(input())
get_mint = lambda : list(map(int, input().split()))
for _ in range(get_int()):
	(X, Y, Z) = sorted(get_mint(), reverse=True)
	color = 0
	if X > 0:
		X -= 1
		color += 1
	if Y > 0:
		color += 1
		Y -= 1
	if Z > 0:
		color += 1
		Z -= 1
	if X > 0 and Y > 0:
		X -= 1
		Y -= 1
		color += 1
	if X > 0 and Z > 0:
		X -= 1
		Z -= 1
		color += 1
	if Y > 0 and Z > 0:
		Y -= 1
		Z -= 1
		color += 1
	print(color)


for i in range(int(input())):
	a = list(map(int, input().split()))
	r = a[0]
	g = a[1]
	b = a[2]
	if r > 1 and g > 1 and (b > 1):
		if r > 2 and g > 2 and (b > 2):
			print('6')
		elif r > 2 or g > 2 or b > 2:
			print('5')
		else:
			print('4')
	elif r > 1 and g <= 1 and (b > 1) or (r > 1 and g > 1 and (b <= 1)) or (r <= 1 and g > 1 and (b > 1)):
		if g == 0 or r == 0 or b == 0:
			print('3')
		else:
			print('4')
	elif r <= 1 and g <= 1 and (b > 1) or (r > 1 and g <= 1 and (b <= 1)) or (r <= 1 and g > 1 and (b <= 1)):
		if r == 0 and g == 0 or (b == 0 and g == 0) or (r == 0 and b == 0):
			print('1')
		elif g == 0 or r == 0 or b == 0:
			print('2')
		else:
			print('3')
	elif r == 0 and b == 0 and (g == 0):
		print('0')
	elif r <= 1 and g <= 1 and (b <= 1):
		if r == 1 and g == 1 and (b == 1):
			print('3')
		elif r == 0 and b == 1 and (g == 1) or (r == 1 and b == 1 and (g == 0)) or (r == 1 and b == 0 and (g == 1)):
			print('2')
		else:
			print('1')


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


def count_colors(colors):
	(zeros, ones, twos) = (colors.count(0), colors.count(1), colors.count(2))
	primary_color = 3 - zeros
	if zeros + ones > 1:
		secondary_color = 0
	elif zeros + ones == 1:
		secondary_color = 1
	elif twos == 1 or twos == 2:
		secondary_color = 2
	elif twos == 3:
		secondary_color = 1
	else:
		secondary_color = 3
	return primary_color + secondary_color
for _ in range(int(input())):
	print(count_colors(list(map(int, input().split()))))


from sys import stdin, stdout
stdint = lambda : int(stdin.readline())
seq = lambda : list(map(int, stdin.readline().strip().split()))
for _ in range(stdint()):
	colors = sorted(seq(), reverse=True)
	count = 0
	if colors[0]:
		colors[0] -= 1
		count += 1
	if colors[1]:
		colors[1] -= 1
		count += 1
	if colors[2]:
		colors[2] -= 1
		count += 1
	if colors[0] and colors[2]:
		colors[0] -= 1
		colors[2] -= 1
		count += 1
	if colors[0] and colors[1]:
		colors[0] -= 1
		colors[1] -= 1
		count += 1
	if colors[1] and colors[2]:
		colors[1] -= 1
		colors[2] -= 1
		count += 1
	print(count)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	ans = 0
	for mask in range(8):
		nx = ny = nz = 0
		if mask & 1:
			nx += 1
			ny += 1
		if mask & 2:
			nx += 1
			nz += 1
		if mask & 4:
			nz += 1
			ny += 1
		if nx > x or ny > y or nz > z:
			continue
		have = bin(mask)[2:].count('1')
		have += (nx < x) + (ny < y) + (nz < z)
		ans = max(ans, have)
	print(ans)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	v = 0
	for i in range(3):
		a[i] = min(3, a[i])
	v = 16 * a[0] + 4 * a[1] + a[2]
	if v == 0:
		ans = 0
	elif v <= 3:
		ans = 1
	elif v <= 0 * 16 + 1 * 4 + 3:
		ans = 2
	elif v <= 1 * 16 + 1 * 4 + 3:
		ans = 3
	elif v <= 2 * 16 + 2 * 4 + 2:
		ans = 4
	elif v <= 2 * 16 + 3 * 4 + 3:
		ans = 5
	else:
		ans = 6
	print(ans)


for itr in range(int(input())):
	lst = list(map(int, input().split()))
	c = 0
	for i in range(len(lst)):
		if lst[i] != 0:
			c += 1
			lst[i] -= 1
	lst.sort()
	if lst[0] >= 2:
		c += 3
		f = 1
	elif lst[0] == 1:
		if lst[2] >= 2:
			c += 2
		else:
			c += 1
	elif lst[1] != 0:
		c += 1
	print(c)


from collections import Counter
t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	(x, y, z) = sorted([x, y, z], reverse=True)
	num_count = Counter({'x': x, 'y': y, 'z': z})
	answer = 0
	colors = ['x', 'y', 'z']
	for i in colors:
		if num_count[i]:
			answer += 1
			num_count[i] -= 1
	for i in range(3):
		for j in range(i + 1, 3):
			a = colors[i]
			b = colors[j]
			if num_count[a] and num_count[b]:
				answer += 1
				num_count[a] -= 1
				num_count[b] -= 1
	print(answer)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	(x, y, z) = sorted([x, y, z])
	count = 0
	if x >= 1:
		count = count + 1
	if y >= 1:
		count = count + 1
	if z >= 1:
		count = count + 1
	if y > 1 and z > 1:
		count = count + 1
	if x > 1 and z > 2:
		count = count + 1
	if x > 2 and y > 2:
		count = count + 1
	print(count)


T = int(input())
for i in range(T):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	if a[0] > 0:
		ans += 1
	if a[1] > 0:
		ans += 1
	if a[2] > 0:
		ans += 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:
		ans += 1
		a[0] -= 1
		a[2] -= 1
	if a[1] > 1 and a[2] > 1:
		ans += 1
		a[1] -= 1
		a[2] -= 1
	print(ans)


T = int(input())
for _ in range(T):
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	r = x[0]
	g = x[1]
	b = x[2]
	n = 0
	if r > 1 and g > 1:
		r = r - 1
		g = g - 1
		n = n + 1
	if r > 1 and b > 1:
		r = r - 1
		b = b - 1
		n = n + 1
	if r > 0:
		n = n + 1
	if g > 1 and b > 1:
		g = g - 1
		b = b - 1
		n = n + 1
	if g > 0:
		n = n + 1
	if b > 0:
		n = n + 1
	print(n)