eolymp
bolt
Try our new interface for solving problems
Problems

Average

Average

In college, a student may take several courses. For each course i, he earns a certain credit ci, and a mark ranging from A to F, which is comparable to a score si, according to the following conversion table:

prb8064.gif

The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,

prb8064_1.gif

An additional treatment is taken for special cases. Some courses are based on "Pass/Not pass" policy, where students earn a mark 'P' for "Pass" and a mark 'N' for "Not pass". Such courses are not supposed to be considered in computation. These special courses must be ignored for computing the correct GPA. Specially, if a student’s credit in GPA computation is 0, his/her GPA will be 0.00.

Input

There are several (about 10) test cases. Each test case starts with a line containing one integer n (1n1000), the number of courses. Then n lines follow, each containing the credit and the mark of one course. Credit is a positive integer less than 10.

Output

For each test case print the GPA, rounded up to two decimal places.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5
2 B
3 D-
2 P
1 F
3 A
2
2 P
2 N
6
4 A
3 A
3 A
4 A
3 A
3 A
Output example #1
2.33
0.00
4.00
Source 2014 Petrozavodsk, Chinese Contest 1, January 27, Problem A