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 Rust (1.42.0) (judge verdict: Accepted)

use proconio::*;

const MOD: u32 = 998244353;

#[derive(Clone, Copy)]
struct ModInt{
    value: u32,
}

impl std::ops::Add for ModInt {
    type Output = ModInt;

    fn add(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (self.value + rhs.value) % MOD,
        }
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: Self) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;

    fn sub(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (MOD + self.value - rhs.value) % MOD,
        }
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: Self) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;

    fn mul(self, rhs: Self) -> Self::Output {
        ModInt {
            value: (self.value as u64 * rhs.value as u64 % MOD as u64) as u32,
        }
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: Self) {
        *self = *self * rhs;
    }
}

impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt {
            value: n % MOD,
        }
    }

    pub fn one() -> ModInt {
        ModInt {
            value: 1,
        }
    }

    pub fn pow(self, mut n: u32) -> ModInt {
        let mut ret = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 > 0 {
                ret *= s;
            }
            s *= s;
            n >>= 1;
        }
        ret
    }
}

impl std::ops::Div for ModInt {
    type Output = ModInt;

    fn div(self, rhs: Self) -> Self::Output {
        self * rhs.pow(MOD-2)
    }
}

impl std::ops::DivAssign for ModInt {
    fn div_assign(&mut self, rhs: Self) {
        *self = *self / rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;

    fn neg(self) -> Self::Output {
        ModInt {
            value: if self.value == 0 { 0 } else { MOD - self.value },
        }
    }
}

struct Combination {
    inv: Vec<ModInt>,
    fact: Vec<ModInt>,
    inv_fact: Vec<ModInt>,
}

impl Combination {
    pub fn new(n: usize) -> Combination {
        let mut inv = vec![ModInt::one(); n];
        let mut fact = vec![ModInt::one(); n];
        let mut inv_fact = vec![ModInt::one(); n];
        for i in 2..n {
            inv[i] = ModInt::new(MOD / i as u32) * (-inv[MOD as usize % i]);
            fact[i] = fact[i-1] * ModInt::new(i as u32);
            inv_fact[i] = inv_fact[i-1] * inv[i];
        }

        Combination {
            inv: inv,
            fact: fact,
            inv_fact: inv_fact,
        }
    }

    pub fn get(&self, x: usize, y: usize) -> ModInt {
        self.fact[x] * self.inv_fact[y] * self.inv_fact[x-y]
    }
}

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize,
    }

    let comb = Combination::new(n+m);
    let mut ans = ModInt::new(0);
    let m = ModInt::new(m as u32);
    for i in 0..=k {
        ans += m * (m - ModInt::one()).pow((n-1-i) as u32) * comb.get(n-1, i);
    }

    println!("{}", ans.value);
}