#include using namespace std; #define int long long typedef pairpint; typedef vectorvint; typedef vectorvpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) templateinline void chmin(T &t,U f){if(t>f)t=f;} templateinline void chmax(T &t,U f){if(t>X[i]>>Y[i]; mapM; vint prime=get_prime(); for(int p:prime){ vint table(25,-1); rep(i,3){ int t=1,c=0; while(Y[i]%t==0){ if(table[c]==-1)table[c]=X[i]%t; else if(table[c]!=X[i]%t){ cout<<-1<1)M[t/p]=table[c-1]; } int ans=0; int m=1; each(i,M)m*=i->fi; each(i,M){ int a=1; each(j,M){ if(i->fi!=j->fi)a*=j->fi; } int inv,tmp; extgcd(a,i->fi,inv,tmp); inv=(inv+i->fi*i->fi)%i->fi; rep(j,i->se)ans=(ans+a*inv)%m; } cout<