#include #include #include using namespace std; int gcd(int a,int b) { while(b) { int g=a%b; a=b; b=g; } return a; } int P,Q; main() { cin>>P>>Q; { int g=gcd(P,Q); P/=g; Q/=g; } vectordiv; for(int i=1;i*i<=Q;i++)if(Q%i==0) { div.push_back(i); if(Q/i>i)div.push_back(Q/i); } vector >ans; for(int N:div)for(int M:div)if(Q/N%M==0) { long p=(long)Q*(N+M); long q=(long)P*N*M; if(p%q==0)ans.push_back(make_pair(p/q*N,p/q*M)); } sort(ans.begin(),ans.end()); cout<p:ans)cout<