import math

n = int(input())
for _ in range(n):
    a, b = map(float, input().split())
    print(int((math.sqrt(a) + math.sqrt(b)) // 1 + 1))