#include using namespace std; using ll = long long; int main(){ // input int N; cin >> N; while(N--){ ll A,B; cin >> A >> B; // solve: meguru binary search ll lo = 1, hi = 1e6; while(hi - lo > 1){ ll mid = (lo + hi) / 2; ll lhs = mid * mid - (A + B); ll rhs = 4 * A * B; bool greater = lhs > 3e9; if(!greater){ if(lhs * lhs > rhs) greater = 1; } // judge if(greater) hi = mid; else lo = mid; } // output cout << hi << endl; } }