import sys import logging import math input = sys.stdin.readline logger = logging.getLogger(__name__) def read(): N = int(input().strip()) AB = [] for i in range(N): a, b = map(int, input().strip().split()) AB.append((a, b)) return N, AB def solve(N, AB): for a, b in AB: xx = 2 * math.sqrt(a * b) + a + b ans = math.floor(math.sqrt(xx)) + 1 print(ans) if __name__ == "__main__": inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))