#include using namespace std; typedef long long ll; typedef long double ld; using P = pair; constexpr ll mod = 1e9+7; #define ALL(x) (x).begin(),(x).end() #define REP(i,n) for(ll (i)=0;(i)<(n);(i)++) #define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++) #define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--) #define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--) #define pb push_back #define eb emplace_back #define mp make_pair #define F first #define S second #define UNIQUE(v) v.erase(unique(ALL(v)),v.end()); template inline void chmin(T& a, T b){ if (a > b){ a = b; } } template inline void chmax(T& a, T b){ if (a < b){ a = b; } } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<> S; REP(lsdgf,S){ ll X,Y; cin >> X >> Y; ll sum = X+Y; ll dif = abs(X-Y); vector divisor(0); for(ll l = 1;l*l <= dif;l++){ if(dif % l == 0){ divisor.eb(l); if(l*l != dif)divisor.eb(dif / l); } } ll count = 0; REP(i,divisor.size()){ if(sum % (divisor[i]+2) != 0)continue; ll B = sum/(divisor[i]+2) + dif/divisor[i]; if(B % 2 != 0)continue; ll C = sum/(divisor[i]+2) - dif/divisor[i]; if(C % 2 != 0)continue; if(B <= 0 || C <= 0)continue; count++; } if(X == Y)count = 100000000000; cout << count << "\n"; } }