#P6262. [集训队互测 2019] 神树大人挥动魔杖

[集训队互测 2019] 神树大人挥动魔杖

Description

There is a row of nn cells and mm people, all starting at cell 11.

Each person may choose to jump forward by 11 cell or by 22 cells. The number of ways to make a 11-cell jump is pp, and the number of ways to make a 22-cell jump is qq. Once a person jumps out of the nn cells, they stop. Note that even on cell nn, one can still choose to jump by 11 or 22 cells.

You need to compute how many ways there are such that every cell is stepped on by at least one person.

Input Format

The first line contains four integers n,m,p,qn,m,p,q.

Output Format

Output the answer modulo 998244353998244353.

10 3 5 6
273459417
2 1 3 4
21
20010910 666 1 1
773849796

Hint

Constraints and Conventions

  • For 100%100\% of the testdata, 1n1091 \le n \le 10^9, 1m6×1041 \le m \le 6 \times 10^4, and 1p,q[0,998244353)1 \le p,q \in [0,998244353).

The limits for each subtask are as follows:

  • Subtask 11 (2020 points): 1n1091 \le n \le 10^9, 1m1001 \le m \le 100;
  • Subtask 22 (1010 points): 1n1031 \le n \le 10^3;
  • Subtask 33 (1010 points): 1n1051 \le n \le 10^5;
  • Subtask 44 (2020 points): 1n1091 \le n \le 10^9, 1m3×1041 \le m \le 3 \times 10^4, p=q=1p=q=1;
  • Subtask 55 (4040 points): no special limits.

Translated by ChatGPT 5