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)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use competitive::prelude::*;
use num::pow::Pow as _;
#[modtype::use_modtype]
type F = modtype::F<998244353u64>;

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
    }
    let mut fact = vec![F(0); n + 1];
    fact[0] = F(1);
    for i in 1..n + 1 {
        fact[i] = fact[i - 1] * F(i as u64);
    }
    let mut ifact = vec![F(0); n + 1];
    ifact[n] = F(1) / fact[n];
    for i in (1..n + 1).rev() {
        ifact[i - 1] = ifact[i] * F(i as u64);
    }
    let n_c_r = |n, k| {
        if k > n {
            F(0)
        } else {
            fact[n] * ifact[k] * ifact[n - k]
        }
    };
    let mut ans = F(0);
    for i in 0..k + 1 {
        let x = F(m as u64);
        let y = (x - F(1)).pow(n - 1 - i);
        let z = n_c_r(n - 1, i);
        ans += x * y * z;
    }
    echo!(ans);
}
*/

fn main() {
    let exe = "/tmp/bin7924E4C8";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";