#Qua2305. TheBigFatDuck equal to TheHamster

TheBigFatDuck equal to TheHamster

Background

In the first three semesters, TheBigFatDuck and TheHamster achieved an equal first place in GPA in the 21 Grade of Information Security. They plan to maintain this status until the end, so that the school's academic affairs office can issue two academic achievement certificates for being ranked first in the program. This will help them secure admission to equally better universities for their postgraduate studies.

Description

After conducting research, TheBigFatDuck and DaddyCheng discovered that each teacher's grading follows the following rules:

  • Because of the similar levels of TheBigFatDuck and TheHamster, each teacher gives them a base points of 9090.
  • Teachers are sympathetic. In order to maintain balance, they give more points to the disadvantaged one. We quantify the sympathy level of each teacher as ai (1ai10)a_i\ (1\le a_i \le 10).
    • If the GPA of TheBigFatDuck is less than or equal to TheHamster's, the teacher will give sympathy points to TheBigFatDuck, i.e. TheBigFatDuck receives 90+ai90 + a_i points while TheHamster receives 9090 points.
    • Conversely, if the GPA of TheBigFatDuck is greater than TheHamster's, the teacher will give sympathy points to TheHamster, i.e. TheBigFatDuck receives 90 points while TheHamster receives 90+ai90 + a_i points.

If TheBigFatDuck and TheHamster have exactly the same curriculum, and we know their total GPA sums totsum, as well as the credits they have already earned is totcredit.

For each course this semester, we know the credit hours cic_i and the teacher's sympathy level aia_i.

Assuming that the order of the courses are randomly arranged, what is the probability that TheBigFatDuck get exactly the same GPA with TheHamster at the end of this semester? Output the result modulo 998244353.

Hint

To calculate the remainder of a fraction nm\dfrac{n}{m} with respect to pp, first, we need to find m1m^{-1} such that mm11(modp)mm^{-1}\equiv 1(\bmod p), then we have nm=n×m1(modp)\dfrac{n}{m} = n\times m^{-1}(\bmod p).

For each course:

Grade=points105Grade = \dfrac{points}{10} - 5

Assuming SS is all courses you had taken, we have:

Totsum=SGrade×CreditsTotsum=\sum_{S} Grade \times Credits $$GPA = \dfrac{\sum_{S}Grade\times Credit}{\sum_{S} Credit}=\dfrac{Totsum}{\sum_{S} Credit} $$

Format

Input

The first line contains 3 numbers n, totsum, totcredit.
n, totcredit are integers while totsum are decimal numbers rounded to one decimal place.
They represents the number of courses they are taking this semester, the total sums of both of them, the total credits they have in common.

The line 22 to the line n+1n+1 contains two integers each, ci,aic_i, a_i, representing the credit hours of the ii-th course and the sympathy level of the teacher for that course.

It is guaranteed that:

  • n100n \le 100
  • 0<totsum<10000 < totsum < 1000
  • 0<credit<4000 < credit < 400
  • 0ai1000 \le a_i \le 100
  • 1ci1001 \le c_i \le 100
  • 0ai×ci1000 \le a_i\times c_i \le 100

Output

An integer representing the probability that TheBigFatDuck tie with TheHamster at the end of this semester, modulo 998244353.

Sample

1 414 100
5 10
0
2 414 100
5 4
2 10
1

Limitation

1s,128MB


As he reached for his phone, a message caught his eye:

DaddyCheng: Why didn't you perform well this time, Yaya? /kel

TheBigFatDuck: well, if we can't make sure rank 1st, at least we can attend postgraduate studies together. In truth, I didn't have any specific aspirations; striving for a high GPA was simply a means to be attractive to the person I liked. DaddyCheng becoming the rank 1st was the most fitting outcome because DaddyCheng was truly outstanding and would represent us into higher educational institutions.