#if defined(_USE_PCH_)
#include "pch.hpp"
#else
#include <bits/stdc++.h>
#endif
#define RNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_<=V_##_END; V_++)
#define IRNG(V_, A_, B_) for(int V_=(A_), V_##_END=(B_); V_>=V_##_END; V_--)
#ifdef _WIN32
#define long __int64
#endif
using namespace std;
const int MAXN=1e6+10; const long MOD=998247353;
int testid,lim,n,S[MAXN]; long p,q;
int kmp[MAXN];
int to(int i,char c){
if(S[i+1]==c) return i+1;
else if(!i) return 0;
else return to(kmp[i],c);
}
long qpow(long x,int p){
long ret=1;
for(;p;p>>=1,x=x*x%MOD){
if(p&1) ret=ret*x%MOD;
}
return ret;
}
long inv(long x){ return qpow(x,MOD-2); }
long P(bool t,int x){
if(!t){
if(x<lim) return qpow(MOD+1-p,x)*p%MOD;
else return qpow(MOD+1-p,lim)*qpow(MOD+1-q,x-lim)%MOD*q%MOD;
}else return qpow(MOD+1-q,x)*q%MOD;
}
struct X{ long k,b; };
X operator+(X x,X y){ return {(x.k+y.k)%MOD,(x.b+y.b)%MOD}; }
X operator-(X x,X y){ return {(MOD+x.k-y.k)%MOD,(MOD+x.b-y.b)%MOD}; }
X operator*(X x,long y){ return {x.k*y%MOD,x.b*y%MOD}; }
X F_[MAXN],*F=F_+1,G_[MAXN],*G=G_+1;
set<int> vis;
int main(){
#if defined(_LOCAL_)
freopen("in","r",stdin);
// freopen("out","w",stdout);
#else
freopen("FiveFiveMod.in","r",stdin);
freopen("FiveFiveMod.out","w",stdout);
#endif
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>testid;
{ long a,b; cin>>a>>b; p=a*qpow(b,MOD-2)%MOD; }
{ long a,b; cin>>a>>b; q=a*qpow(b,MOD-2)%MOD; }
cin>>lim>>n;
RNG(i,1,n) cin>>S[i];
RNG(i,2,n,j=0){
while(j&&S[j+1]!=S[i]) j=kmp[j];
if(S[j+1]==S[i]) j++;
kmp[i]=j;
}
F[-1]={1,0};
{
auto a=qpow(MOD+1-p,lim)*(MOD+1-q)%MOD,b=MOD+1-a;
auto x=P(0,S[1]),y=P(1,S[1]);
auto c=S[1]<=lim?a:MOD+a-x,d=S[1]>lim?b:b-y;
F[1]=F[-1]*(c+x)-F[-1]*(c*d%MOD*inv(d+y)%MOD)-X{0,c%MOD*inv(d+y)%MOD}-X{0,1};
F[1]=F[1]*inv((c*y%MOD*inv(d+y)%MOD+x)%MOD);
}
RNG(i,1,n-1){
auto t=S[i]>lim;
F[i+1]=F[i];
int j=kmp[i];
long tot=P(S[i]>lim,S[i+1]);
vis.insert(S[i+1]);
while(true){
j=kmp[j];
if(!vis.count(S[j+1])){
tot=(tot+P(t,S[j+1]))%MOD;
F[i+1]=F[i+1]-F[j+1]*P(t,S[j+1]);
vis.insert(S[j+1]);
}
if(!j) break;
}
vis.clear();
if(!t) j=-1;
F[i+1]=F[i+1]-F[j]*(MOD+1-tot)-X{0,1};
F[i+1]=F[i+1]*inv(P(t,S[i+1]));
}
auto ans=(MOD-F[n].b)*inv(F[n].k)%MOD;
cout<<ans<<"\n";
}