#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include #include using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int T; cin>>T; ll x,y; while(T--){ cin>>x>>y; if(x A; for(int i=2;i*i<=s;i++){ if(s%i==0){ A.push_back(i); if(i*i!=s) A.push_back(s/i); } } ll cnt=0; for(auto c:A){ if(c==2){ if(x!=y) continue; cnt+=x-1; continue; } if(t%(c-2)!=0) continue; ll d=s/c; ll e=t/(c-2); if(d%2 != e%2) continue; if(d+e<2 || d-e<2) continue; cnt++; } cout<