#pragma GCC optimize("Ofast") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while(q--){ int h,w; cin >> h >> w; bool done = false; for(int _i=1;_i<=2;_i++){ for(int _j=1;_j<=2;_j++){ if(done)break; bool ok = true; int sum = 0; int turn = _i; while(sum < h){ sum += turn; turn = 3-turn; } if(sum != h){ ok = false; continue; } sum = 0; turn = _j; while(sum < w){ sum += turn; turn = 3-turn; } if(sum != w){ ok = false; continue; } if(ok)done = true; int t1 = _i, t2 = _j; for(int i=0;i