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# (.NET Core 3.1.201) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long m = sc.NextLong();
        long k = sc.NextLong();

        long mod = 998244353;

        long answer = 0;
        long tmpBefore = 0;
        for (int i = 0; i <= k; i++)
        {
            if (i == 0)
            {
                tmpBefore = Mul(m, Pow(m - 1, n - i - 1, mod), mod);
            } else
            {
                tmpBefore = Div(tmpBefore, m - 1, mod);
            }
            long tmpAnswer = Mul(tmpBefore, Combination(n - 1, i, mod), mod);
            answer += tmpAnswer;
            answer = answer % mod;
        }

        Console.WriteLine(answer);
    }

    // Combination（mod版）
    private static long Combination(long a, long b, long c)
    {
        long numerator = 1;
        long denominator = 1;
        for (long i = 1; i <= b; i++)
        {
            numerator = Mul(numerator, a - i + 1, c);
            denominator = Mul(denominator, i, c);
        }
        return Div(numerator, denominator, c);
    }

    // 掛け算（mod版）
    private static long Mul(long a, long b, long c)
    {
        return ((a % c) * (b % c)) % c;
    }

    // 割り算（mod版）
    private static long Div(long a, long b, long c)
    {
        return Mul(a, Pow(b, c - 2, c), c);
    }

    // べき乗（mod版）
    private static long Pow(long a, long b, long c)
    {
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % c;
        }
        else if (b % 2 == 0)
        {
            long d = Pow(a, b / 2, c);
            return d * d % c;
        }
        else
        {
            return a * Pow(a, b - 1, c) % c;
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}