// verify https://yukicoder.me/problems/no/186 #include using namespace std; #include using ll=long long; ll extGcd(ll a,ll b,ll& p,ll &q){ if(b==0) {p=1; q=0; return a;} ll d = extGcd(b,a%b,q,p); q -= a/b * p; return d; }using namespace std; using ll=long long; const ll MOD=1e9+7; // Note that mod may not be prime. ll modInv(ll a,ll mod){ long long x,y; extGcd(a,mod,x,y); return (x%mod+mod)%mod; } // all m must be coprime each other. // O(K^2), where K is size of b and m // return ll crt(vector b,vector m){ int k=b.size(); vector t(k); ll r; auto calc=[&](int end,ll mod){ ll sum = 0; r=1; for(int i=0;i __int128 int main(){ int n; cin>>n; vector x(n),y(n); for(int i=0;i>x[i]>>y[i]; map> mcb; for(int i=0;i mp; ll v=y[i]; for(ll j=2;j*j<=v;j++){ if(v%j==0){ int cnt=0; while(v%j==0) cnt++,v/=j; mp[j]=cnt; } } if(v>1){ mp[v]=1; } for(auto& p:mp){ if(mcb.count(p.first)){ ll prem = 1; for(int j=0;j b,m; for(auto& e:mcb){ b.push_back(e.second.second); ll tmp=1; for(int i=0;i