#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN=1e6+5;
const int MOD=998244353;
int n,m,k;
long long dp[MAXN];
long long pref[MAXN];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>k;
for(int i=1;i<=k;i++) dp[i]=m;
for(int i=1;i<=k;i++) pref[i]=pref[i-1]+dp[i];
for(int i=k+1;i<=n;i++)
{
    int l=max(k,i-k+1);
    dp[i]=((long long)dp[i]+((pref[i-1]-pref[l-1]+MOD)%MOD)*(m-1))%MOD;
    dp[i]=((long long)dp[i]+dp[i-k]*m)%MOD;
    pref[i]=(pref[i-1]+dp[i])%MOD;
}
cout<<dp[n]<<endl;
return 0;
}
