4
14723
5512
100
28436
33903
100
84816
75747
100
92281
31380
100 1
45819
95605
83
1848
1357
3031
2097 3824
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

test = int(raw_input())
while test:
    n1 = int(raw_input())
    n2 = int(raw_input())
    result = gcd(n1,n2)
    k = int(raw_input())
    for i in xrange(n1,n1+k+1):
        for j in range(n2-k+(i-n1),n2+k-(i-n1)+1):
            temp = gcd(i,j)
            if(temp > result):
                result = temp
    for i in xrange(n1-k,n1+1):
        for j in range(n2-(i+k-n1),n2+(i+k-n1)+1):
            temp = gcd(i,j)
            if(temp > result):
                result = temp
    test -= 1
    print result