#pragma GCC optimize("Ofast") #include #include using namespace std; using ll=long long; ll mod=998244353; ll sub(ll a, ll b) {return ((a-b)%mod+mod)%mod;} ll mul(ll a, ll b) {return (a*b)%mod;} ll mul(ll a, ll b, ll c) { return mul(a,mul(b,c));} ll pow_mod(ll a, ll n){ ll x=1; while (n){ n--; x*=a; x%=mod; } return x; } ll second(ll s1, ll s2, ll l_inv){ return sub(s2,mul(mul(s1,s1),l_inv)); } ll third(ll s1, ll s2, ll s3, ll l_inv){ ll X=sub(s3,3*mul(s2,s1,l_inv)); X+=2*mul(pow_mod(s1,3),l_inv,l_inv); return X%mod; } ll forth(ll s1, ll s2, ll s3, ll s4, ll l_inv){ ll X=sub(s4,4*mul(s3,s1,l_inv)); X+=6*mul(s2,pow_mod(s1,2),pow_mod(l_inv,2)); X-=3*mul(pow_mod(s1,4),pow_mod(l_inv,3)); X%=mod; if (X<0) X+=mod; return X; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; ll a; vector> A(N+1,vector (5,1)); for (int i=1; i<=N; i++){ cin >> a; for (int j=1; j<=4; j++){ A[i][j]=(A[i][j-1]*a)%mod; } } vector L_inv(N+1,0); L_inv[1]=1; int q,r; for (int i=2;i<=N;i++){ q=mod/i; r=mod%i; L_inv[i]=(-L_inv[r]*q)%mod+mod; L_inv[i]%=mod; } ll Q; cin >> Q; ll m,U,V,W,B; ll b1,b2,b3,b4; ll s1,s2,s3,s4; ll L,l_inv; ll X; for (int q=0; q> m >> U >> V >> W; if (U>V) swap(U,V); if (m==0){ cin >> B; b1=B; b2=(b1*B)%mod; b3=(b2*B)%mod; b4=(b3*B)%mod; ; if (U