def main(): from math import floor from decimal import Decimal from sys import stdin from builtins import input, int, map readline = stdin.readline N = int(input()) for _ in [0]*N: a, b = map(int, readline().split()) a = Decimal(a).sqrt() b = Decimal(b).sqrt() print(floor(a+b+1)) main()