def sqrte100(n): left = 0 right = 10 ** 105 X = n * 10 ** 200 while right - left > 1: mid = (right + left) // 2 if mid * mid <= X: left = mid else: right = mid return left e100 = 10 ** 100 N = int(input()) for _ in range(N): A, B = [int(x) for x in input().split()] X = sqrte100(A) + sqrte100(B) X //= e100 X += 1 print(X)