#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; vector divisor(ll x){ set s; for(ll i=1;i*i<=x;i++){ if(x%i==0){ s.insert(i); s.insert(x/i); } } vector res; for(auto y:s) res.push_back(y); return res; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll p,q; cin>>p>>q; if(p==2*q){ cout<<1<q){ cout<<0< A=divisor(q); sort(ALL(A)); vector> ANS; if((2*q)%p==0){ ll k=2*q/p; if(q%k) ANS.push_back({k,k}); } int a=A.size(); rep(i,a){ if(p-A[i]<=0) continue; auto t=lower_bound(ALL(A),p-A[i])-A.begin(); if(t==a) continue; if(A[t]+A[i]==p){ ANS.push_back({q/A[i],q/A[t]}); } } int n=ANS.size(); sort(ALL(ANS)); cout<