from decimal import Decimal import math for _ in range(int(input())): a, b = map(Decimal, input().split()) l, r = -1, 1 << 30 while r - l > 1: x = (l + r) // 2 if 0 < x ** 4 - 2 * (a + b) * x ** 2 + (a + b) ** 2 - 4 * a * b: r = x else: l = x print(r)