from decimal import Decimal import math for _ in range(int(input())): a, b = map(Decimal, input().split()) k = a + b + 2 * Decimal(math.sqrt(a*b)) # print(math.floor(Decimal(math.sqrt(k))) + 1) x = math.floor(Decimal(math.sqrt(a)) + Decimal(math.sqrt(b)) + 1) print(x)