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: v = math.floor(math.sqrt(a) + math.sqrt(b)) xs = [v-2, v-1, v, v+1, v+2] left = a * b * 4 for x_i in xs: right = (x_i * x_i - a - b) ** 2 if left < right: ans = x_i break print(ans) if __name__ == "__main__": inputs = read() outputs = solve(*inputs) if outputs is not None: print("%s" % str(outputs))