#P6016. [CSGRound3] 出游

[CSGRound3] 出游

Description

The school organized a summer trip, and registration will close on day TT.

There are nn students. Student ii has aia_i friends. The friendship relation is directed. In other words, if student Z has student Y as a friend, it does not mean student Y must have student Z as a friend. Also, a student may be their own friend.

On day 00, each student decides whether to join the trip. Student ii decides to join with probability pip_i, and decides not to join with probability 1pi1-p_i.

During the next TT days, each student will decide again whether to join. On that day, student ii decides to join if and only if at least one of their friends decided to join on the previous day; otherwise, they do not join.

You need to compute the expected number of students who join the trip. Output the answer modulo 998244353998244353.

Input Format

The first line contains two integers n,Tn, T, as described above.

The next nn lines each start with two integers pi,aip_i, a_i. Here, pip_i is the probability (under modulo 998244353998244353) that student ii decides to join on day 00, and aia_i is the number of their friends. Then follow aia_i integers indicating their friends.

Output Format

Output one integer, the answer modulo 998244353998244353.

3 1
1 2 2 3
0 1 3
499122177 1 2
1
3 3
1 2 2 3
0 1 3
233 1 2
466

Hint

[Sample 1 Explanation]

Day Probability that the first student goes Probability that the second student goes Probability that the third student goes
00 11 00 12\frac 12
11 12\frac 12 00

[Constraints]

This problem uses bundled testdata.

  • Subtask 1 (3 points): T=0T = 0.
  • Subtask 2 (14 points): T=1T = 1.
  • Subtask 3 (33 points): n10n \le 10.
  • Subtask 4 (20 points): T5×103T \le 5 \times 10^3.
  • Subtask 5 (15 points): n100n \le 100.
  • Subtask 6 (15 points): No special constraints.

For 100%100\% of the testdata: 1n5001 \le n \le 500, 0T1090 \le T \le 10^9, 0pi<9982443530 \le p_i < 998244353, 0ain0 \le a_i \le n, and all friends are distinct.

Translated by ChatGPT 5