#include #include #include #include using ll = int64_t; std::tuple exgcd(const ll &a,const ll &b){ if(b==0){ ll x=1,y=0; return std::make_tuple(a,x,y); } auto[d,x,y] = exgcd(b, a%b); const ll tmpy = y; y=x-a/b*y; x=tmpy; return std::make_tuple(d,x,y); } ll inv(const ll &n,const ll &p){ auto[d,x,y]=exgcd(n, p); x=(x%p+p)%p; return x; } int main(){ ll N; std::cin>>N; std::vector p(N),n(N); for(ll i{0};i>p[i]>>n[i]; } ll prod{1}; for(ll pi:p){ prod=prod*pi; } }