Code:
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i < B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
#define db double
using namespace std;
const int mo = 998244353;
ll ksm(ll x, ll y) {
ll s = 1;
for(; y; y /= 2, x = x * x % mo)
if(y & 1) s = s * x % mo;
return s;
}
const int N = 1005;
int n, K; ll q, X, Y, ni_1_q;
ll f[N][N], g[N][N];
#define mem(f) memset(f, 0, sizeof f)
ll aq[N], a[N], b[N], c[N], d[N], e[N * 2];
void qmo(ll *a, ll *b, int k) {
fd(i, 2 * k, k + 1) if(a[i]) {
int c = i - (k + 1);
fo(j, 1, k) a[c + j] = (a[c + j] - a[i] * b[j]) % mo;
a[i] = 0;
}
}
ll calc(int k) {
mem(g); mem(f);
aq[0] = 1; fo(i, 1, k + 1) aq[i] = aq[i - 1] * q % mo;
fo(j, 1, k + 1) g[0][j] = 1;
fo(i, 1, k) {
fo(j, 1, k / i) {
f[i][j] = 0;
fo(u, 1, i) f[i][j] += g[u - 1][j + 1] * g[i - u][j] % mo * (1 - q) % mo * aq[j] % mo;
f[i][j] %= mo;
}
fd(j, k, 1) g[i][j] = (f[i][j] + g[i][j + 1]) % mo;
}
a[0] = 1;
fo(i, 1, k + 1) {
a[i] = 0;
fo(j, 0, i - 1) a[i] += a[i - j - 1] * (1 - q) % mo * g[j][1] % mo;
a[i] %= mo;
}
if(n + 1 <= k) return a[n + 1] * ni_1_q % mo;
k ++;
fo(i, 1, k) b[i] = -g[i - 1][1] * (1 - q) % mo;
fo(i, 1, k / 2) swap(b[i], b[k - i + 1]); b[k + 1] = 1;
mem(c); mem(d);
c[1] = 1; d[0] = 1;
int y = n + 1;
for(; y; y /= 2) {
if(y & 1) {
mem(e);
fo(i, 0, k) fo(j, 0, k) e[i + j] = (e[i + j] + c[i] * d[j]) % mo;
qmo(e, b, k);
fo(i, 0, k) d[i] = e[i];
}
mem(e);
fo(i, 0, k) fo(j, 0, k) e[i + j] = (e[i + j] + c[i] * c[j]) % mo;
qmo(e, b, k);
fo(i, 0, k) c[i] = e[i];
}
ll ans = 0;
fo(i, 1, k) ans += d[i] * a[i] % mo;
return (ans % mo + mo) % mo * ni_1_q % mo;
}
int main() {
scanf("%d %d %lld %lld", &n, &K, &X, &Y);
q = X * ksm(Y, mo - 2) % mo;
ni_1_q = ksm(mo + 1 - q, mo - 2);
ll ans = (calc(K) - calc(K - 1) + mo) % mo;
pp("%lld\n", ans);
}