n = int(input()) for i in range(n): c = input().split() a = int(c[0]) b = int(c[1]) ok = a + b ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if mid * mid * mid * mid - 2 * mid * mid * a - 2 * mid * mid * b + a * a + b * b - 2 * a * b > 0: ok = mid else: ng = mid print(ok)