Moejy0viiiiiv 在平面直角坐标系上抢红包。从 (0,0)(0,0)(0,0) 出发,每天中午有 A/1996488707A/1996488707A/1996488707 的概率向上走一格,有 B/1996488707B/1996488707B/1996488707 的概率向右走一格,有 1−A/1996488707−B/19964887071-A/1996488707-B/19964887071−A/1996488707−B/1996488707 的概率立即停止行动(之后也不再行动),三种事件两两不会同时发生;Moejy0viiiiiv 在第 NNN 天傍晚离开平面直角坐标系(总共至多走 NNN 格)。
已知一个常数 DDD,在所有 (xD,yD)(0≤x,y)(xD, yD)(0 \leq x, y)(xD,yD)(0≤x,y) 处有一个红包;还有 KKK 个坑,分别在 (x1,y1),(x2,y2),(x3,y3),⋯,(xK,yK)(x_1, y_1), (x_2, y_2), (x_3, y_3), \cdots, (x_K, y_K)(x1,y1),(x2,y2),(x3,y3),⋯,(xK,yK),走入坑中将在接下来的回合中无法行动。
Moejy0viiiiiv 会抢走所有她经过的红包(包含 (0,0)(0,0)(0,0))问最终期望抢到的红包数量,输出这个值 mod998244353,注意 1996488707mod998244353=1。
Moejy0viiiiiv is collecting red envelopes on a rectangular plane. She starts at (0,0)(0,0)(0,0). Every day at noon, she walks from (x,y)(x, y)(x,y) to (x,y+1)(x,y+1)(x,y+1) with probability A/1996488707A/1996488707A/1996488707, and to (x+1,y)(x+1,y)(x+1,y) with probability B/1996488707B/1996488707B/1996488707, and stops immediately with probability 1−A/1996488707−B/19964887071-A/1996488707-B/19964887071−A/1996488707−B/1996488707 (once she stops, she will never move again). Besides, she also stops after walking for NNN days.
With a given constant integer DDD, there’s a red envelope at each (xD,yD)(0≤x,y)(xD, yD)(0 \leq x, y)(xD,yD)(0≤x,y). There’re also KKK barriers at (x1,y1),(x2,y2),(x3,y3),...,(xK,yK)(x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_K, y_K)(x1,y1),(x2,y2),(x3,y3),...,(xK,yK) (barriers never coincide with red envelopes). If she walks to a barrier, she will stop immediately.
Moejy0viiiiiv will collect each red envelope she passes by (including (0,0)(0,0)(0,0)). What’s the expected number of red envelopes Moejy0viiiiiv collects after NNN days? Output the answer mod998244353. Notice that 1996488707mod998244353=1.