#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 pw[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]=0;
dp[k]=m;
for(int i=1;i<=k;i++) pref[i]=pref[i-1]+dp[i];

pw[0]=1;
for(int i=1;i<=n;i++) pw[i]=(long long)pw[i-1]*m%MOD;

for(int i=k+1;i<=n;i++)
{
    dp[i]=(long long)(dp[i]+(pref[i-1]-pref[i-k]+MOD)*(m-1))%MOD;
    dp[i]=(dp[i]+pw[i-k+1])%MOD;
    pref[i]=(pref[i-1]+dp[i])%MOD;
}
cout<<dp[n]<<endl;
return 0;
}
