import math from sys import stdin n = int(input()) for _ in range(n): a, b = list(map(int, stdin.readline().split())) temp = a**0.5 + b**0.5 tempAns = math.ceil(temp) if abs(tempAns-temp) < 10 ** -7: tempAns += 1 print(tempAns)