#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lint = long long int; long long int INF = 1001001001001001LL; int inf = 1000000007; long long int MOD = 1000000007LL; double PI = 3.1415926535897932; templateinline void chmin(T1 &a,const T2 &b){if(a>b) a=b;} templateinline void chmax(T1 &a,const T2 &b){if(a struct Mint{ T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;}; Mint operator-(Mint a) const{return Mint(v)-=a;}; Mint operator*(Mint a) const{return Mint(v)*=a;}; Mint operator/(Mint a) const{return Mint(v)/=a;}; Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} bool operator <(const Mint a)const{return v struct SquareMatrix{ vector> dat; size_t N; SquareMatrix() = default; SquareMatrix(size_t N, T val = T()):N(N){ dat = vector> (N, vector (N)); for(size_t i=0;i& operator[](size_t k){return dat[k];}; const vector& operator[](size_t k) const {return dat[k];}; SquareMatrix operator*(const SquareMatrix &B) const{ SquareMatrix res(N, 0); for(size_t i=0;i>=1; } return res; } }; int main() { using modint = Mint; lint n, m, k; cin >> n >> m >> k; lint p; // 状態が変化する確率 lint pp, qq; cin >> pp >> qq; p = pp * modinv(qq, MOD) % MOD; SquareMatrix mat(2); mat[0][0] = mat[1][1] = modint(1 - p); mat[1][0] = mat[0][1] = modint(p); mat = mat.pow(k); modint tapi = 0; modint oka = 0; for(int i = 1; i <= n; i++) { lint b; cin >> b; if(i <= m) tapi += b; else oka += b; } modint ak = mat[0][0]; modint bk = mat[1][0]; cout << (tapi * ak + oka * bk).v << endl; return 0; }