import math def main(): a,b=map(int,input().split()) print(int(math.sqrt(a)+math.sqrt(b))+1) for _ in range(int(input())): main()