#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; const double PI=acos(-1); ll gcd(ll x,ll y){ return y==0?x:gcd(y,x%y); } int main(){ ll P,Q; cin>>P>>Q; ll g=gcd(P,Q); P/=g; Q/=g; set> cand; for(ll c=1;c*c<=Q;c++){ if(Q*Q%c==0){ { ll d1=Q*Q/c; ll d2=c; if((d1+Q)%P==0 && (d2+Q)%P==0){ ll n=(d1+Q)/P; ll m=(d2+Q)/P; //cand.emplace_back(n,m); cand.insert(make_pair(n,m)); } } } } vector> ans; for(auto [m,n]:cand){ ans.emplace_back(m,n); if(m!=n){ ans.emplace_back(n,m); } } cout<