#include #include #include #include #include #include #include using namespace std; typedef long long ll; void solve(){ int x, y; cin >> x >> y; if(x < y) swap(x, y); if(x == y){ int ans = 0; // a = 1 ans += x-1; // b = c for(int i = 3; i*i <= x; i++){ if(x%i == 0) ans++; } cout << ans << endl; return; } int ans = 0; for(int s = 1; s*s <= x-y; s++){ if((x-y)%s != 0) continue; { int t_ = (x-y)/s; int a = s+1; if((x+y)%(a+1) == 0){ int t = (x+y)/(a+1); if(t > t_ && t%2 == t_%2) { ans++; } } } if(s*s != x-y){ int t_ = s; int a = (x-y)/t_+1; if((x+y)%(a+1) == 0){ int t = (x+y)/(a+1); if(t > t_ && t%2 == t_%2) { ans++; cout << a << ' ' << (t+t_)/2 << ' ' << (t-t_)/2 << endl; } } } } cout << ans << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int s; cin >> s; for(int i = 0; i < s; i++) solve(); }