#include #define rep(i,n) for(int i=0;i> S; while (S--) { int x,y; cin >> x >> y; ll ans=0; for(int k=2;k<=sqrt(x+y);k++){ if((x+y)%k==0){ ll a=k-1; if(a==1){ if(a*y==x){ans+=(x+y)/(a+1)-1;} } else if(a>1&&(a*y-x)>0&&(a*y-x)%(a*a-1)==0){ if(y-a*((a*y-x)/(a*a-1))>0){ ans++; } } a=(x+y)/k-1; if(a<=1)continue; if((a*y-x)>0&&(a*y-x)%(a*a-1)==0){ if(y-a*((a*y-x)/(a*a-1))>0){ ans++; } } } } cout << ans << '\n'; } return 0; }