import math N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] v = 10**30 vh = 10**15 for a,b in AB: print((math.isqrt(a*v)+math.isqrt(b*v))//vh+1)