#AGC035F. [AGC035F] Two Histograms

[AGC035F] Two Histograms

Score : 18001800 points

Problem Statement

We have a square grid with NN rows and MM columns. Takahashi will write an integer in each of the squares, as follows:

  • First, write 00 in every square.
  • For each i=1,2,...,Ni=1,2,...,N, choose an integer kik_i (0kiM)(0\leq k_i\leq M), and add 11 to each of the leftmost kik_i squares in the ii-th row.
  • For each j=1,2,...,Mj=1,2,...,M, choose an integer ljl_j (0ljN)(0\leq l_j\leq N), and add 11 to each of the topmost ljl_j squares in the jj-th column.

Now we have a grid where each square contains 00, 11, or 22. Find the number of different grids that can be made this way, modulo 998244353998244353. We consider two grids different when there exists a square with different integers.

Constraints

  • 1N,M5×1051 \leq N,M \leq 5\times 10^5
  • NN and MM are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the number of different grids that can be made, modulo 998244353998244353.

1 2
8

Let (a,b)(a,b) denote the grid where the square to the left contains aa and the square to the right contains bb. Eight grids can be made: (0,0),(0,1),(1,0),(1,1),(1,2),(2,0),(2,1),(0,0),(0,1),(1,0),(1,1),(1,2),(2,0),(2,1), and (2,2)(2,2).

2 3
234
10 7
995651918
314159 265358
70273732