#include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} ll p,q; vectorf(int n,vector>&pr){ if(n==pr.size())return{1}; vectorV=f(n+1,pr),re; auto[x,c]=pr[n]; ll z=1; rep(j,c+1){ for(auto y:V){ re.push_back(y*z); } z*=x; } return re; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin>>p>>q; ll r=q; vector>ans; ll x=2; vector>pr; while(x*x<=q){ int cnt=0; while(q%x==0){ cnt++; q/=x; } if(cnt>0)pr.push_back(make_pair(x,2*cnt)); x++; } if(q>1)pr.push_back(make_pair(q,2)); vectorV=f(0,pr); for(auto y:V){ if((y+r)%p==0&&(r*r/y+r)%p==0){ ans.push_back(make_pair((y+r)/p,(r*r/y+r)/p)); } } cout<