#include #include using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { long long a, b; cin >> a >> b; long long ok = 1e12; long long ng = 0; long long subres = -2 * a * b + a * a + b * b; while (ng + 1 < ok) { long long mid = (ok + ng) / 2; if (pow(mid, 4) - 2 * a * pow(mid, 2) - 2 * b * pow(mid, 2) + subres > 0) { ok = mid; } else { ng = mid; } } cout << ok << endl; } return 0; }