import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) template `mod=`(x,y) = x = ((x mod y)+y).mod(y) template scan2 = (scan(), scan()) template scan3 = (scan(), scan()) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc scanf(): float = read().parseFloat proc toInt(c:char): int = return int(c) - int('0') proc xgcd(a,b:int):(int,int,int)= var b = b x0=1 y0=0 x1=0 y1=1 q:int a = a while b!=0: (q,a,b) = (a.div(b),b,a.mod(b)) (x0,x1)=(x1,x0-q*x1) (y0,y1)=(y1,y0-q*y1) return (a,x0,y0) # modの逆元 proc modinv(a,m:int):int= var (g,x,y)=xgcd(a,m) if g!=1: return -1 else: return x mod m # modPow # 無いので作る # なんか畳み込んで上手いことやるやつ proc modPow(x,b,m:int):int= if x == 0: return 0 #echo x,", ",b if b == 1: return x return (modPow((x^2) mod m, b div 2, m) * x^(b mod 2)) mod m proc solve():int= var n = scan() m = scan() k = scan() p = scan() q = scan() b = newseqwith(n,scan()) md = 10^9+7 (p,q) = (p.div(gcd(p,q)),q.div(gcd(p,q))) var multi = (modPow((q-2*p).mod(md),k,md)*modInv(modPow(q,k,md),md)).mod(md) for i in 0..