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