output_description: Print the number of different grids that can be made, modulo 998244353.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
attempt: def p(i):
      ans = 1
      while i != 1:
          ans *= i
          i -= 1
      return ans
  
  
  def comb_dp_sub(n, r):
      global comb_table
      if r == 0 or n == r:
          return 1
      else:
          return comb_table[n - 1][r] + comb_table[n - 1][r - 1]
  
  
  def comb_dp(n, r):
      global comb_table
      comb_table = [[0] * (n + 1) for _ in range(n + 1)]
      for i in range(n + 1):
          for j in range(i + 1):
              comb_table[i][j] = comb_dp_sub(i, j)
      return comb_table[n][r]
  
  
  n, m = map(int, input().split())
  
  st = ((n + 1) ** m) * ((m + 1) ** n)
  general = 0
  for i in range(1, min(n, m) + 1):
      general += comb_dp(n, i) * comb_dp(m, i) * p(i)
  
  print(st - general)
  
problem_description: Statement
  
  We have a square grid with N rows and M columns. Takahashi will write an
  integer in each of the squares, as follows:
  
    * First, write 0 in every square.
    * For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k_i squares in the i-th row.
    * For each j=1,2,...,M, choose an integer l_j (0\leq l_j\leq N), and add 1 to each of the topmost l_j squares in the j-th column.
  
  Now we have a grid where each square contains 0, 1, or 2. Find the number of
  different grids that can be made this way, modulo 998244353. We consider two
  grids different when there exists a square with different integers.
samples: [{"input": "1 2", "output": "8\n    \n\nLet (a,b) denote the grid where the square to the left contains a and the\nsquare to the right contains b. Eight grids can be made:\n(0,0),(0,1),(1,0),(1,1),(1,2),(2,0),(2,1), and (2,2).\n\n* * *"}, {"input": "2 3", "output": "234\n    \n\n* * *"}, {"input": "10 7", "output": "995651918\n    \n\n* * *"}, {"input": "314159 265358", "output": "70273732"}]