4
14723
5512
100
28436
33903
100
84816
75747
100
92281
31380
100 1
45819
95605
83
1848
1357
3031
2097 3824
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''


for _ in range (input()):
	n1 = int(raw_input())
	n2 = int(raw_input())
	k = int(raw_input())
	smaller = min(n1,n2)
	greater = max(n1,n2)
	adder = 0 
	for i in range(smaller + k,0,-1):
		if(i<=smaller):
			factor1 = min(smaller%i,i - smaller%i)
		else:
			factor1 = i - smaller%i
		if(i<=greater):
			factor2 = min(greater%i,i - greater%i)
		else:
			factor2 = i - greater%i
		count = factor1 + factor2
		 
		if(count <= k):
			print i
			break