#ABC473G. 翻牌消除 / Wipeout

翻牌消除 / Wipeout

Problem Statement

There are NN cards arranged face down in a row, each with one of the integers 1,2,,N1,2,\dots,N written on its face. The order of these cards is determined uniformly at random from the N!N! possible orders. You know that there is exactly one card with each of the integers 1,2,,N1,2,\dots,N written on its face and that the cards were arranged uniformly at random, but you have no other information about the integers written on the faces of the cards.

You play the following game.

  • Initially, let the variable x=1x=1.
  • As long as xNx \le N, repeat the following operation. One operation consists of the following three steps.
  • Specify one card and turn it face up.
  • If the integer written on the card is xx, eat that card and add 11 to xx.
  • Otherwise, turn that card face down. You can permanently remember the integer written on that card.

You always act so that the expected value of the total number of operations until all cards have been eaten is minimized. In this case, what is the probability that the total number of operations is KK? Find it modulo 998244353998244353.

Definition of probability modulo 998244353998244353

It can be proved that the sought probability is always a rational number. Also, under the constraints of this problem, it can be proved that when the rational number to be found is expressed as an irreducible fraction PQ\frac{P}{Q}, we have Q≢0(mod998244353)Q {{}\not\equiv{}} 0 \pmod{998244353}. Therefore, there is a unique integer RR satisfying $R \times Q \equiv P \pmod{998244353}, 0 \leq R \lt 998244353$. Output this RR.

Constraints

  • All input values are integers.
  • 1N5×1051 \le N \le 5 \times 10^5
  • NK109N \le K \le 10^9

Input

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

  • NN KK

Output

Output the answer.

3 4
499122177

For this input, N=3N=3. Let us call the cards a,b,ca,b,c in the order they are arranged. Below is an example of your actions when acting so that the expected value of the total number of operations is minimized.

  • First, turn aa face up.
    • If 11 is written on aa, eat that card.
      • Next, turn bb face up.
        • If 22 is written on bb, eat that card.
          • Next, turn cc face up; since 33 is necessarily written on it, eat it. In this case, you eat all cards in three operations, and the probability of this happening is 1/61/6.
        • If 33 is written on bb, turn that card face down.
          • Next, turn cc face up; since 22 is necessarily written on it, eat it. After that, turn bb face up and eat it. In this case, you eat all cards in four operations, and the probability of this happening is 1/61/6.
    • If 22 is written on aa, turn that card face down.
      • Next, turn bb face up.
        • If 11 is written on bb, eat that card.
          • Next, turn aa face up and eat it. Next, turn cc face up; since 33 is necessarily written on it, eat it. In this case, you eat all cards in four operations, and the probability of this happening is 1/61/6.
        • If 33 is written on bb, turn that card face down.
          • At this point, it has become clear which integer is written on every one of the cards. So, perform three operations and eat all the cards in order of their numbers. In this case, you eat all cards in five operations, and the probability of this happening is 1/61/6.
    • If 33 is written on aa, turn that card face down.
      • Next, turn bb face up.
        • If 11 is written on bb, eat that card.
          • Next, turn cc face up; since 22 is necessarily written on it, eat it. After that, turn aa face up and eat it. In this case, you eat all cards in four operations, and the probability of this happening is 1/61/6.
        • If 22 is written on bb, turn that card face down.
          • At this point, it has become clear which integer is written on every one of the cards. So, perform three operations and eat all the cards in order of their numbers. In this case, you eat all cards in five operations, and the probability of this happening is 1/61/6.

Combining everything, the probability that the total number of operations is 33 is 1/61/6, the probability that it is 44 is 1/21/2, and the probability that it is 55 is 1/31/3. For this sample, output 499122177499122177, which represents 1/21/2 modulo 998244353998244353.

3 6
0
500000 777777
251612105