import sys import logging import math input = sys.stdin.readline logger = logging.getLogger(__name__) def read(): N = int(input().strip()) AB = [] for i in range(N): a, b = map(int, input().strip().split()) AB.append((a, b)) return N, AB def judge(x, a, b): left = a * b * 4 right = (x * x - a - b) * (x * x - a - b) return left < right def solve(N, AB): for a, b in AB: ok = 10**11 ng = 2 while abs(ok - ng) > 1: x = (ok + ng) // 2 if judge(x, a, b): ok = x else: ng = x ans = 0 for x in (ok-1, ok, ok+1): if judge(x, a, b): ans = x break if ans == 0: raise RuntimeError else: print(ans) if __name__ == "__main__": inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))