n = int(input()) for i in range(n): a,b = map(int,input().split()) a **= 0.5 b **= 0.5 print(int(a + b) + 1)