#include<iostream> #include<algorithm> #define ll long long #define maxn 200010 #define INF 1000000000000000000 usingnamespacestd;
constint p = 998244353;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1, x = x * x % p) if (n & 1) s = s * x % p; return s; }
int pri[maxn], cnt, mu[maxn], d[maxn]; bool isp[maxn]; voidinit_isp(int n){ mu[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, mu[i] = -1; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; mu[i * pri[j]] = -mu[i]; } } }
ll n, m, P, Q, f[maxn], g[maxn], a[maxn]; ll in[maxn], dn[maxn], an[maxn]; intmain(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cin >> n >> m >> P >> Q; init_isp(200000); for (int i = 1; i <= m; ++i) for (int j = i; j <= m; j += i) d[j] += i; for (int i = 1; i <= m; ++i) in[i] = pow_mod(i, n), dn[i] = pow_mod(d[i], n); for (int i = 1; i <= m; ++i) for (int j = i; j <= m; j += i) f[j] = (f[j] + mu[i] * in[i] % p * dn[j / i]) % p; //for (int i = 1; i <= m; ++i) cout << i << " " << f[i] << "\n"; return 0; for (int i = 1; i <= m; ++i) for (int j = i; j <= m; j += i) g[j] = (g[j] + mu[j / i] * f[i]) % p; //for (int i = 1; i <= m; ++i) cout << i << " " << g[i] << "\n"; return 0; int ans = 0; for (int k = 1; k <= P - 1; ++k) for (int i = 1; i * k < P && i <= Q; ++i) ans = (ans - in[i] * g[k]) % p; for (int i = 1; i <= m; ++i) for (int j = 1; j <= m / i; ++j) a[i] = (a[i] + i * j) % p; for (int i = 1; i <= m; ++i) an[i] = pow_mod(a[i], n); for (int k = 1; k <= Q; ++k) for (int d = 1; d <= m / k; ++d) ans = (ans + mu[d] * an[d * k]) % p; cout << (ans + p) % p << "\n"; return0; }