#arc163f. [arc163_f]Many Increasing Problems

[arc163_f]Many Increasing Problems

Problem Statement

PCT-kun created the following problem.

Increasing Problem

You are given a length-NN sequence of non-negative integers A1,A2,dots,ANA_1,A_2,\\dots,A_N. You can perform the following operation any number of times (possibly zero).

  • Choose an integer ii such that 1leileN1 \\le i \\le N, and increase or decrease AiA_i by 11.

Your goal is to make AA non-decreasing. Find the minimum number of operations required to achieve this goal.

Thinking that this problem is too easy to be placed at the end of the contest, PCT-kun has revised it as follows.

Many Increasing Problems

There are MNM^N integer sequences AA of length NN where all elements are between 11 and MM, inclusive. Find the sum of the answers to Increasing Problem for all those sequences, modulo 998244353998244353.

Solve Many Increasing Problems.

Constraints

  • 1leN,Mle1051 \\le N,M \\le 10^5

Input

The input is given from Standard Input in the following format:

NN MM

Output

Print the answer to Many Increasing Problems.


Sample Input 1

2 2

Sample Output 1

1

Let us solve Increasing Problem for all sequences of length 22 where all elements are between 11 and 22, inclusive.

  • For A=(1,1)A=(1,1), the answer is 00.
  • For A=(1,2)A=(1,2), the answer is 00.
  • For A=(2,1)A=(2,1), the answer is 11.
  • For A=(2,2)A=(2,2), the answer is 00.

Therefore, the final answer is 0+0+1+0=10+0+1+0=1.


Sample Input 2

6 4

Sample Output 2

14668

Sample Input 3

163 702

Sample Output 3

20728656

Sample Input 4

98765 99887

Sample Output 4

103564942