from math import ceil def bisect(x): left, right = 0, 10**5 for _ in range(30): mid = (left + right) / 2 if mid**2 >= x: right = mid else: left = mid return right for _ in range(int(input())): a, b = map(int, input().split()) sqa = bisect(a) sqb = bisect(b) print(ceil(sqa + sqb))