#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; void solve() { ll a, b; cin >> a >> b; ull min_x = max(1, sqrt(a) + sqrt(b) - 1); ull x = min_x; while(1) { ull x4 = x * x * x * x; ull sb = 2 * x * x * (a + b); ull ab2 = (max(a, b) - min(a, b)) * (max(a, b) - min(a, b)); if (ab2 + x4 > sb) { // ab2 > sub - x4 cout << x << endl; return; } x += 1; } } int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { solve(); } return 0; }