# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# CGPA, the Golden Egg!

By Jakaria_MU · Limits 1s, 512 MB

Jenith is a student of CSE of Metropolitan University (MU). Recently her fifth term’s result has been published. She obtained CGPA 4 out of 4. Her classmates ask her to calculate their CGPA. Actually she helps her friends to calculate their CGPA from the first term. Sometimes she feels bore, so she wants to write a program now that will help her friends to calculate their CGPA. As you are a very good programmer she needs your help.

CGPA stands for “Cumulative Grade Point Average”. It is calculated based on all the courses you take along with the total number of credit hours. The total marks or numeral grades of a course is multiplied by the total credits of that course. Then summing the results of all the courses divide by the total credits of a term or semester you will get your CGPA.

In Metropolitan University important courses including major and non-major courses carry 3 to 4 credits and some less important courses including lab courses carry 1 to 2 credits.

80-100A+4.00
75-79A3.75
70-74A-3.50
65-69B+3.25
60-64B3.00
55-59B-2.75
50-54C+2.50
45-49C2.25
40-44C-2.00
0-39F0.00

## Input

The first line of input contains an integer T (T ≤ 50) denoting the number of test cases. Next line contains an integer C the number of courses you take in a term or semester. Next C lines contains two numbers (can be float or double) m, n (0 ≤ m ≤ 100, n ≥ 1), the marks of a course and the credit of that course.

## Output

For each test case print the case no and print the floating point result R (two digits after decimal) that denotes your CGPA. If your input m contains less than 40 then print "Sorry, you have failed in F courses!" Where F is an integer that denotes the number of courses you have failed.

## Sample

InputOutput
3
4
79.5  3
88  3
100  3
75  2
5
97  3
92  1.5
69  2
75  3
55  3
4
56.5  2
55.5  3
36  3
25  4 
Case 1: 3.89
Case 2: 3.52
Case 3: Sorry, you have failed in 2 courses!


Note: If you have failed in 1 course, then you have to print "Sorry, you have failed in 1 course!". Otherwise print "Sorry, you have failed in F courses!", where F denotes the the total number of courses you have failed.

### Statistics

82% Solution Ratio

nazmul.me92Earliest, Jul '17

Nasif_44thFastest, 0.0s

Mili290Lightest, 0 B

touhidurrrShortest, 267B