import sys input = sys.stdin.readline N = int(input()) AB = [tuple(map(int,input().split())) for _ in range(N)] for a,b in AB: v = a**0.5 + b**0.5 for x in range(int(v)-2, int(v)+3): if a+b-x*x < -2*(a*b)**0.5: print(x) break else: assert False