A certain type of steel is graded according to the following conditions.

1. Hardness of the steel must be greater than 50
2. Carbon content of the steel must be less than 0.7
3. Tensile strength must be greater than 5600

The grades awarded are as follows:
Grade is 10 if all three conditions are met
Grade is 9 if conditions (1) and (2) are met
Grade is 8 if conditions (2) and (3) are met
Grade is 7 if conditions (1) and (3) are met
Grade is 6 if only one condition is met
Grade is 5 if none of the three conditions are met

Write a program to display the grade of the steel, based on the values of hardness, carbon content and tensile strength of the steel, given by the user.

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

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains three numbers hardness, carbon content and tensile strength of the steel. 

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

For each test case, print Grade of the steel depending on Conditions, in a new line.

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

- 1 ≤ T ≤ 1000
- 0 ≤ hardness, carbon content, tensile strength ≤ 10000

----- Sample Input 1 ------ 
3 
53 0.6 5602
45 0 4500
0 0 0 

----- Sample Output 1 ------ 
10
6
6

Difficulty: EASY

Solutions:
for _ in range(int(input())):
	(h, c, t) = map(float, input().split())
	con1 = h > 50
	con2 = c < 0.7
	con3 = t > 5600
	if con1 and con2 and con3:
		print('10')
	elif con1 and con2:
		print('9')
	elif con2 and con3:
		print('8')
	elif con1 and con3:
		print('7')
	elif con1 or con2 or con3:
		print('6')
	else:
		print('5')


a = int(input())
for i in range(a):
	(b, c, d) = map(float, input().split())
	if b > 50 and c < 0.7 and (d > 5600):
		print(10)
	elif b > 50 and c < 0.7:
		print(9)
	elif d > 5600 and c < 0.7:
		print(8)
	elif b > 50 and d > 5600:
		print(7)
	elif b > 50 or c < 0.7 or d > 5600:
		print(6)
	else:
		print(5)


t = int(input())
for i in range(t):
	(h, c, s) = map(float, input().split())
	if h > 50 and c < 0.7 and (s > 5600):
		print('10')
	elif h > 50 and c < 0.7:
		print('9')
	elif c < 0.7 and s > 5600:
		print('8')
	elif h > 50 and s > 5600:
		print('7')
	elif h > 50 or c < 0.7 or s > 5600:
		print('6')
	else:
		print('5')


n = int(input())
for i in range(n):
	(hardness, carbon, tensile) = list(map(float, input().split()))
	if hardness > 50 and carbon < 0.7 and (tensile > 5600):
		print('10')
	elif hardness > 50 and carbon < 0.7:
		print('9')
	elif carbon < 0.7 and tensile > 5600:
		print('8')
	elif hardness > 50 and tensile > 5600:
		print('7')
	elif hardness > 50 and carbon >= 0.7 and (tensile <= 5600) or (hardness <= 50 and carbon < 0.7 and (tensile <= 5600)) or (hardness <= 50 and carbon >= 0.7 and (tensile > 5600)):
		print('6')
	elif hardness <= 50 and carbon >= 0.7 and (tensile <= 5600):
		print('5')


t = int(input())
for i in range(t):
	(h, c, t) = map(float, input().split())
	(x, y, z) = (h > 50.0, c < 0.7, t > 5600.0)
	if x and y and z:
		grade = 10
	elif x and y:
		grade = 9
	elif y and z:
		grade = 8
	elif x and z:
		grade = 7
	elif not (x or y or z):
		grade = 5
	else:
		grade = 6
	print(grade)


for i in range(int(input())):
	(H, C, T) = map(float, input().split())
	if int(H) > 50 and float(C) < 0.7 and (int(T) > 5600):
		print('10')
	elif int(H) > 50 and float(C) < 0.7:
		print('9')
	elif int(H) > 50 and int(T) > 5600:
		print('7')
	elif float(C) < 0.7 and int(T) > 5600:
		print('8')
	elif int(H) > 50 or float(C) < 0.7 or int(T) > 5600:
		print('6')
	else:
		print('5')


t = int(input())
for i in range(t):
	(a, b, c) = map(float, input().split())
	x = y = z = 0
	if a > 50:
		x = 1
	if b < 0.7:
		y = 1
	if c > 5600:
		z = 1
	r = str(x) + str(y) + str(z)
	if r == '111':
		print(10)
	elif r == '110':
		print(9)
	elif r == '011':
		print(8)
	elif r == '101':
		print(7)
	elif r == '001' or r == '100' or r == '010':
		print(6)
	else:
		print(5)


for t in range(int(input())):
	steel = input().split()
	hard = int(steel[0]) > 50
	carbon = float(steel[1]) < 0.7
	tension = int(steel[2]) > 5600
	if hard and carbon and tension:
		print(10)
	elif hard and carbon and (not tension):
		print(9)
	elif not hard and carbon and tension:
		print(8)
	elif hard and (not carbon) and tension:
		print(7)
	elif hard and (not carbon) and (not tension) or (not hard and (not carbon) and tension) or (not hard and carbon and (not tension)):
		print(6)
	elif not hard and (not carbon) and (not tension):
		print(5)


T = int(input())
for _ in range(T):
	(h, c, t) = map(float, input().split())
	(rh, rc, rt) = (50, 0.7, 5600)
	if h > rh and c < rc and (t > rt):
		print(10)
	elif h > rh and c < rc:
		print(9)
	elif c < rc and t > rt:
		print(8)
	elif h > rh and t > rt:
		print(7)
	elif h > rh or c < rc or t > rt:
		print(6)
	else:
		print(5)


for i in range(int(input())):
	(H, C, T) = [float(x) for x in input().split()]
	HB = H > 50
	CB = C < 0.7
	TB = T > 5600
	if HB and CB and TB:
		print(10)
	elif HB and CB:
		print(9)
	elif CB and TB:
		print(8)
	elif HB and TB:
		print(7)
	elif HB or CB or TB:
		print(6)
	else:
		print(5)


t = int(input())
for i in range(t):
	d = []
	(a, b, c) = map(float, input().split())
	if a > 50.0:
		d.append(1)
	if b < 0.7:
		d.append(2)
	if c > 5600.0:
		d.append(3)
	if len(d) == 3:
		print(10)
	elif len(d) == 1:
		print(6)
	elif len(d) == 0:
		print(5)
	elif 1 not in d:
		print(8)
	elif 2 not in d:
		print(7)
	else:
		print(9)


def main():
	t = input()
	for i in range(int(t)):
		(hardness, carbon, strength) = input().split()
		condition = []
		if int(hardness) > 50:
			condition.append(True)
		else:
			condition.append(False)
		if float(carbon) < 0.7:
			condition.append(True)
		else:
			condition.append(False)
		if int(strength) > 5600:
			condition.append(True)
		else:
			condition.append(False)
		if False not in condition:
			print(10)
		elif condition[0] == True and condition[1] == True and (condition[2] == False):
			print(9)
		elif condition[0] == False and condition[1] == True and (condition[2] == True):
			print(8)
		elif condition[0] == True and condition[1] == False and (condition[2] == True):
			print(7)
		elif condition[0] == True or condition[1] == True or condition[2] == True:
			print(6)
		else:
			print(5)
main()


for _ in range(int(input())):
	(x, y, z) = map(float, input().split())
	(c1, c2, c3) = (x > 50.0, y < 0.7, z > 5600.0)
	if c1 and c2 and c3:
		grade = 10
	elif not (c1 or c2 or c3):
		grade = 5
	elif c1 and c2:
		grade = 9
	elif c2 and c3:
		grade = 8
	elif c1 and c3:
		grade = 7
	else:
		grade = 6
	print(grade)


for _ in range(int(input())):
	(x, y, z) = map(float, input().split())
	if x > 50 and y < 0.7 and (z > 5600):
		print('10')
	elif x > 50 and y < 0.7:
		print('9')
	elif z > 5600 and y < 0.7:
		print('8')
	elif x > 50 and z > 5600:
		print('7')
	elif x > 50 or y < 0.7 or z > 5600:
		print('6')
	else:
		print('5')


import math

def solution():
	pass
T = int(input())
for _ in range(T):
	(h, cc, ts) = map(float, input().split())
	(f1, f2, f3) = (False, False, False)
	if h > 50:
		f1 = True
	if cc < 0.7:
		f2 = True
	if ts > 5600:
		f3 = True
	if f1 == True and f2 == True and (f3 == True):
		print(10)
	elif f1 == True and f2 == True:
		print(9)
	elif f2 == True and f3 == True:
		print(8)
	elif f1 == True and f3 == True:
		print(7)
	elif f1 == True or f2 == True or f3 == True:
		print(6)
	else:
		print(5)


for i in range(int(input())):
	(hard, cc, tensile) = map(float, input().split())
	if hard > 50 and cc < 0.7 and (tensile > 5600):
		print(10)
	elif hard > 50 and cc < 0.7:
		print(9)
	elif cc < 0.7 and tensile > 5600:
		print(8)
	elif hard > 50 and tensile > 5600:
		print(7)
	elif hard > 50 or cc < 0.7 or tensile > 5600:
		print(6)
	else:
		print(5)


def grade(a, b, c):
	if a > 50 and b < 0.7 and (c > 5600):
		return 10
	elif a > 50 and b < 0.7:
		return 9
	elif b < 0.7 and c > 5600:
		return 8
	elif a > 50 and c > 5600:
		return 7
	elif a > 50 or b < 0.7 or c > 5600:
		return 6
	else:
		return 5
n = int(input())
for i in range(0, n):
	(a, b, c) = list(map(float, input().split()))
	print(grade(a, b, c))


t = int(input())
while t:
	(a, b, c) = map(float, input().split())
	if a > 50 and b < 0.7 and (c > 5600):
		print(10)
	elif a > 50 and b < 0.7:
		print(9)
	elif b < 0.7 and c > 5600:
		print(8)
	elif a > 50 and c > 5600:
		print(7)
	elif a > 50 or b < 0.7 or c > 5600:
		print(6)
	else:
		print(5)
	t -= 1


T = int(input())
for _ in range(T):
	lst = [i for i in input().strip().split()][0:3]
	dict = {}
	dict['H'] = float(lst[0])
	dict['C'] = float(lst[1])
	dict['T'] = float(lst[2])
	if dict['H'] > 50 and dict['C'] < 0.7 and (dict['T'] > 5600):
		print(10)
	elif dict['H'] > 50 and dict['C'] < 0.7:
		print(9)
	elif dict['C'] < 0.7 and dict['T'] > 5600:
		print(8)
	elif dict['H'] > 50 and dict['T'] > 5600:
		print(7)
	elif dict['H'] > 50 or dict['C'] < 0.7 or dict['T'] > 5600:
		print(6)
	else:
		print(5)


for i in range(int(input())):
	(h1, c1, t1) = map(float, input().split())
	if h1 > 50 and c1 < 0.7 and (t1 > 5600):
		print('10')
	elif h1 > 50 and c1 < 0.7:
		print('9')
	elif c1 < 0.7 and t1 > 5600:
		print('8')
	elif h1 > 50 and t1 > 5600:
		print('7')
	elif h1 > 50 or c1 < 0.7 or t1 > 5600:
		print('6')
	else:
		print('5')


(a, b, c) = (50, 0.7, 5600)
t = int(input())
for _ in range(t):
	l = list(input().split())
	n1 = int(l[0])
	n2 = float(l[1])
	n3 = int(l[2])
	if n1 > a and n2 < b and (n3 > c):
		print(10)
	elif n1 > a and n2 < b:
		print(9)
	elif n2 < b and n3 > c:
		print(8)
	elif n1 > a and n3 > c:
		print(7)
	elif n1 > a or n2 < b or n3 > c:
		print(6)
	else:
		print(5)


for i in range(int(input())):
	(s, d, f) = map(float, input().split())
	if s > 50 and d < 0.7 and (f > 5600):
		print('10')
	elif s > 50 and d < 0.7:
		print('9')
	elif d < 0.7 and f > 5600:
		print('8')
	elif s > 50 and f > 5600:
		print('7')
	elif s > 50 or d < 0.7 or f > 5600:
		print('6')
	else:
		print('5')


t = int(input())
for _ in range(t):
	(h, cc, ts) = list(map(float, input().split()))
	cond1 = h > 50
	cond2 = cc < 0.7
	cond3 = ts > 5600
	if cond1 and cond2 and cond3:
		print(10)
	elif cond1 and cond2 and (not cond3):
		print(9)
	elif cond2 and cond3:
		print(8)
	elif cond1 and cond3 and (not cond2):
		print(7)
	elif cond1 and (not cond2) and (not cond3) or (cond2 and (not cond1) and (not cond3)) or (cond3 and (not cond2) and (not cond1)):
		print(6)
	else:
		print(5)