#include #include #include #include constexpr int primitive_root(int m){ if(m==2)return 1; if(m==167772161)return 3; if(m==469762049)return 3; if(m==754974721)return 11; if(m==998244353)return 3; return 0; } template struct F_p{ using value_type = int64_t; static constexpr inline value_type get_mod(){return p;} value_type value; constexpr F_p():value(value_type{}){} templateconstexpr F_p(T v):value(static_cast(v<0?v%p+p:v%p)){} // operator +, -, *, /, ^ constexpr F_p operator + (const F_p& other)const{ return F_p(*this) += other; } constexpr F_p operator - (const F_p& other)const{ return F_p(*this) -= other; } constexpr F_p operator * (const F_p& other)const{ return F_p(*this) *= other; } constexpr F_p operator / (const F_p& other)const{ return F_p(*this) /= other; } template constexpr F_p operator ^ (const T other)const{ return F_p(*this) ^= other; } constexpr F_p &operator += (const F_p& other){ value+=other.value; if(value>p)value-=p; return *this; } constexpr F_p &operator -= (const F_p& other){ value-=other.value; if(value<0)value+=p; return *this; } constexpr F_p &operator *= (const F_p& other){ value*=other.value; if(value>p)value%=p; return *this; } constexpr F_p &operator /= (const F_p& other){ value*=other.inverse(); if(value>p)value%=p; return *this; } template constexpr F_p &operator ^= (const T n){ value = mpow(n).value; return *this; } // ext_gcd,inverse,mpow static constexpr value_type ext_gcd(value_type a,value_type b,value_type& x,value_type& y){ if(b==0){x=1,y=0;return a;} value_type d=ext_gcd(b,a%b,y,x); y-=a/b*x;return d; } constexpr value_type inverse()const{ value_type x,y; ext_gcd(value,p,x,y); return x<0?x%p+p:x%p; } template static constexpr value_type inverse(T val){ value_type x,y; ext_gcd(val,p,x,y); return x<0?x%p+p:x%p; } template constexpr F_p mpow(T n)const{ F_p res(1),vn(*this); while(n){ if(n&1)res*=vn; vn*=vn; n>>=1; } return res; } template static constexpr T mpow(T a,U b){ F_p x(a); return static_cast(x.mpow(b).value); } // operator iostream constexpr friend std::istream &operator >> (std::istream& is,F_p& fp){ is>>fp.value; return is; }constexpr friend std::ostream &operator << (std::ostream& os,const F_p& fp){ os< struct number_theoretic_transform{ using value_type = F_p; using vector_t = std::vector; template static constexpr value_type pow(value_type v,T t){return v^t;} static constexpr int64_t get_mod(){return MOD;} number_theoretic_transform() = default; static void ntt(vector_t& a,bool inv=false){ const int n = std::size(a); for(int i=0,j=1;j+1>1;k>(i^=k);k>>=1); if(i static vector_t convolution(std::vector const& a,std::vector const& b){ const int sz_a = std::size(a); const int sz_b = std::size(b); const int m = sz_a+sz_b-1; int n = 1; while(n(a[i]); for(int i=0;i(b[i]); ntt(ntt_a); ntt(ntt_b); for(int i=0;i; struct NTT{ using NTT_1 = number_theoretic_transform<998244353,3>; using NTT_2 = number_theoretic_transform<754974721,11>; using NTT_3 = number_theoretic_transform<469762049,3>; NTT(){} static std::tuple ext_gcd(int64_t a,int64_t b){ if(b==0)return {a,1,0}; auto[d,y,x]=ext_gcd(b,a%b); y-=a/b*x;return {d,x,y}; } static constexpr inline int64_t mod(int64_t a,int64_t m){ a%=m;return(a<0?a+m:a); } static int64_t mod_inv(int64_t a,int64_t m){ auto[d,x,y]=ext_gcd(a,m);return(d!=1?-1:mod(x,m)); } static int64_t gerner (std::vector b,std::vector m,int64_t const MOD){ using i64 = int64_t; assert(0 coeffs(std::size(m),1); std::vector constants(std::size(m),0); for(int k=0;k static std::vector convolution(std::vectorconst& a,std::vectorconst& b,const int64_t MOD){ auto ntt1 = NTT_1::convolution(a,b); auto ntt2 = NTT_2::convolution(a,b); auto ntt3 = NTT_3::convolution(a,b); const int n = std::size(a)+std::size(b)-1; const int m = 3; std::vector conv(n),mods = {NTT_1::get_mod(),NTT_2::get_mod(),NTT_3::get_mod()}; for(int i=0;i b = {static_cast(ntt1[i].value), static_cast(ntt2[i].value), static_cast(ntt3[i].value)}; conv[i] = gerner(b,mods,MOD); } return conv; } }; int main(){ using namespace std; std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); constexpr char newl = '\n'; int n; cin>>n; vector a(n+1),b(n+1); for(auto& ai:a)cin>>ai; for(auto& bi:b)cin>>bi; auto c = NTT::convolution(a,b,1e9+7); //for(auto ci:c)cout< ans = 0; for(int i=0;i<=n and i>n; vector a(n),b(n); for(int i=0;i>a[i]>>b[i]; auto c = NTT_998244353::convolution(a,b); cout<<0<