#P5850. Sum of Products of Permutations

    ID: 19078 Type: Default 1000ms 256MiB

Sum of Products of Permutations

Sum of Products of Permutations

Given two integers n and k, consider all sequences \(a_1, a_2, \ldots, a_n\) such that:

  • The sequence length is exactly \(n\).
  • Each \(a_i\) is an integer in the range \([1,k]\).
  • All \(a_i\) are distinct.

The value of a sequence is defined as the product \(a_1 \times a_2 \times \cdots \times a_n\). Your task is to compute the sum of the values of all different legal sequences, and output the answer modulo \(998244353\).

Note: Two sequences are considered different if they differ in at least one position.

inputFormat

The input contains two integers n and k in a single line, separated by a space.

outputFormat

Output a single integer, representing the sum of all valid sequences' values modulo \(998244353\).

sample

2 4
70