mod = 998244353 omega = pow(3,119,mod) rev_omega = pow(omega,mod-2,mod) N = 2*10**5 g1 = [1]*(N+1) # 元テーブル g2 = [1]*(N+1) #逆元テーブル inv = [1]*(N+1) #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inv[i]=( ( -inv[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inv[i]) % mod ) inv[0]=0 def _ntt(f,L,reverse=False): F=[f[i] for i in range(L)] n = L.bit_length() - 1 base = omega if reverse: base = rev_omega if not n: return F size = 2**n wj = pow(base,2**22,mod) res = [0]*2**n for i in range(n,0,-1): use_omega = pow(base,2**(22+i-n),mod) res = [0]*2**n size //= 2 w = 1 for j in range(0,L//2,size): for a in range(size): res[a+j] = (F[a+2*j] + w * F[a+size+2*j]) % mod t = (w * wj) % mod res[L//2+a+j] = (F[a+2*j] + t * F[a+size+2*j]) % mod w = (w * use_omega) % mod F = res return res def ntt(f,L=0): l = len(f) if not L: L = 1<<((l-1).bit_length()) while len(f) c[i] = sum(a[j] * b[i - j] for j in range(i + 1)) % 998244353. It returns an empty list if at least one of a and b are empty. Constraints ----------- > len(a) + len(b) <= 8388609 Complexity ---------- > O(n log n), where n = len(a) + len(b). """ n = len(a) m = len(b) if n == 0 or m == 0: return [] if min(n, m) <= 0: return _convolution_naive(a, b) if a is b: return _convolution_square(a) return _convolution_fft(a, b) def taylor_shift(f,a): g = [f[i]*g1[i]%mod for i in range(len(f))][::-1] e = [g2[i] for i in range(len(f))] t = 1 for i in range(1,len(f)): t = t * a % mod e[i] = e[i] * t % mod res = convolution(g,e)[:len(f)] return [res[len(f)-1-i]*g2[i]%mod for i in range(len(f))] def inverse(f,limit): assert(f[0]!=0) l = len(f) L = 1<<((l-1).bit_length()) n = L.bit_length()-1 f = f[:L] f+=[0]*(L-len(f)) res = [pow(f[0],mod-2,mod)] for i in range(1,n+1): h = convolve(res,f[:2**i],2**i) h = [(-h[i]) % mod for i in range(2**i)] h[0] = (h[0]+2) % mod res = convolve(res,h,2**i) return res[:limit] import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def cmb(n,r): if r < 0 or n < r: return 0 return g1[n] * (g2[n-r] * g2[r] % mod) % mod N = int(input()) a,b,c,d = mi() A,B = mi() P = li() p,q = abs(c-a),abs(d-b) x,y = A*pow(2*A+2*B,mod-2,mod) % mod,B*pow(2*A+2*B,mod-2,mod) % mod X = [0] * (2*N+1) Y = [0] * (2*N+1) for i in range(2*N+1): if 2*i+p <= 2*N: X[2*i+p] = (g2[i] * g2[i+p] % mod) * pow(x,2*i+p,mod) % mod if 2*i+q <= 2*N: Y[2*i+q] = (g2[i] * g2[i+q] % mod) * pow(y,2*i+q,mod) % mod XY = convolve(X,Y,2*N+1) f = [0] * (N+1) for i in range(N+1): f[i] = XY[2*i] * g1[2*i] % mod p,q = 0,0 X = [0] * (2*N+1) Y = [0] * (2*N+1) for i in range(2*N+1): if 2*i+p <= 2*N: X[2*i+p] = (g2[i] * g2[i+p] % mod) * pow(x,2*i+p,mod) % mod if 2*i+q <= 2*N: Y[2*i+q] = (g2[i] * g2[i+q] % mod) * pow(y,2*i+q,mod) % mod XY = convolve(X,Y,2*N+1) g = [0] * (N+1) for i in range(N+1): g[i] = XY[2*i] * g1[2*i] % mod ig = inverse(g,N+1) h = convolve(f,ig,N+1) res = 0 for i in range(N): res += h[i+1] * P[i] res %= mod print(res)