Problem:
Score : 500 points

Problem Statement

There are N blocks arranged in a row. Let us paint these blocks.

We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.

Find the number of ways to paint the blocks under the following conditions:

For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors.

There may be at most K pairs of adjacent blocks that are painted in the same color.

Since the count may be enormous, print it modulo 998244353.

Constraints

All values in input are integers.

1 \leq N, M \leq 2 \times 10^5

0 \leq K \leq N - 1

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the answer.

Sample Input 1

3 2 1

Sample Output 1

6

The following ways to paint the blocks satisfy the conditions: 112, 121, 122, 211, 212, and 221. Here, digits represent the colors of the blocks.

Sample Input 2

100 100 0

Sample Output 2

73074801

Sample Input 3

60522 114575 7559

Sample Output 3

479519525

Solution in C++ (GCC 9.2.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
3 2 0 = 2 //121 212
3 2 1 = 6 // 2*(2+1)
3 2 2 = 8 // 2^3

2通りとれるばしょ
4 2 1だとして
1121
ペアは3か所。そのうち1か所まで
2 * 

DP

DP[K]
DP[0] = M;
1回目のループ
DP[0] = DP[0] * (M-1)
DP[1] = DP[0];
DP(NK)になってまう

3 3 0
3 * 2 * 2
=12
3 3 1 = 3^2 3^(N-K)
3 3 2 = 3^1
330+
112
113
221
223
331
332
122
133
211
233
311
322
=9通り
3*3

3 3 2
=3通り

1=0+1
2=0+1+2

3 3 0 = 12
3 3 1 = 12 + 9同じペアをくっつけてカウント？
3 3 2 = 12 + 9 + 3

4 4 0 = 4*3*3*3
4 4 1 = 4 * 3 * 3 * 3C1 = (N-1)CK
4 4 2 = 4 * 3 * 2C2？
1122 1133
1112 1113とか
3通りある。3C2か
1123
1223
1233
1112
1222
1122
1111

4 4 0 = 4*3*3*3* 3C0//1234
4 4 1 = 4*3*3* 3C1//1123 1223 1233
4 4 2 = 4*3 * 3C2//1122 1112 1222
4 4 3 = 4 * 3C3 //1111
M * (M-1)^(N-1-K)*(N-1)CK

3 2 0 = 2 //121 212
2 * 1 * 1 * 2C0
*/

const int MAX = 210000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2; i<MAX; i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n, int k){
  if(n<k)
    return 0;
  if(n<0 || k<0)
    return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  COMinit();
  
  ll N, M, K; cin >> N >> M >> K;
  ll ans = 0;
  vector<ll> Z(N, 1);
  rep(i, N){
    Z[i+1] = Z[i] * (M-1);
    Z[i+1] %= MOD;
  }
  for(ll k=K; k>=0; k--){
//cout << "k;"<<k<<" ans:"<<ans<<endl;
//M * (M-1)^(N-1-K)*(N-1)CK
    ll tmp = M * Z[N-1-k];
    tmp %= MOD;
    tmp *= COM(N-1, k);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}