from math import floor from decimal import Decimal from sys import stdin N = int(input()) for i in range(N): a, b = map(int, stdin.readline().split()) a = Decimal(a).sqrt() b = Decimal(b).sqrt() print(floor(a+b+1))