GPA

Time limit2sMemory limit512 MB

Summary
Given a catalog of courses with units, major requirements, and each student's grades, print each student's overall GPA and the GPA for every major whose requirements they completed.
Level

Medium4 of 10

Topics
Hash map, String, Implementation, Simulation
Solved
No attempts yet

Problem

For many students, at graduation, all that matters is one number: the GPA. Except, then, many employers seem to be not so interested in how a CSCI or EE student did in "Introduction to Origami;" somehow, they seem to care more about performance in CSCI104 or CSCI270 or CSCI360. Strange! As a result, the "Major GPA" has become a thing, which only includes classes "in the major." But if you are double- or triple-majoring, then computing all your multiple major GPAs becomes rather time-consuming. Isn't that what computers are for? In fact, it is. Thanks for pointing this out!

You will be given the complete course catalog of a university (course names and units), as well as the major requirements for each of the majors. Then, you will be given a list of students, and for each student all the classes they have taken and the grades they received. You will output, for each student, the overall GPA, and the GPA for each major such that the student completed all requirements for this major. The GPA is weighted: for each class the student took, you multiply the student's grade (a number between 0.0 and 4.0) by the number of units of the class. In the end, you divide the sum of all these weighted grades by the total number of units the student took. That's the student's GPA. Similarly for the major GPA, except you only sum the classes relevant for the major.

Input

The first line contains a number 1≤K≤1001 \le K \le 100, which is the number of input data sets in the file. This is followed by KK data sets of the following form:

The first line of the data set contains three integers 1≤C≤100001 \le C \le 10000, 1≤M≤5001 \le M \le 500, 1≤s≤10001 \le s \le 1000 (the number of classes, the number of majors, and the number of students who are graduating).

This is followed by CC lines, each describing a class ii, by giving its name nin_i and number of units uiu_i. The name consists of 2-4 uppercase letters, followed immediately by exactly 3 digits. The number of units is an integer between 1 and 6, inclusive.

Next come the MM majors. The first line of a major jj contains first a string of 2-4 uppercase letters (the name of the major), and then the number rj≥1r_j \ge 1 of classes the major requires (an integer). This is followed by rjr_j lines, each containing exactly one class name. The class name will be a legal name from the first CC lines. The total number of units of any major will add up to at most 128.

Finally, we have the ss students. For each student kk, you first get the integer tk≥1t_k \ge 1 of classes the student has taken. This is followed by tkt_k lines, each containing first the name of a class (a legal string from the first CC lines), followed by the student's grade in the class, a floating point number between 0.0 and 4.0. No student ever takes more than 200 units total. And no student will ever take the same class twice.

Output

For each data set, first output "Data Set x:" on a line by itself, where x is its number. Then, output the overall GPA and all applicable major GPAs, for each student, in the order the majors were listed in the input file. Specifically, first print a line "Student k", where k is the student's number. Then print a line with the student's GPA. Then, for each major for which the student took all required classes, print the name of the major, followed by the student's GPA in that major. (See below for the format.) All GPAs should be rounded to two decimals. Each data set should be followed by a blank line.

Examples1

  1. Example 1

    Input
    1
    5 3 1
    CSCI104 4
    CSCI109 2
    EE364 3
    ISE330 4
    ORIG101 1
    CSCI 3
    CSCI104
    CSCI109
    EE364
    CENG 2
    CSCI104
    EE364
    ISE 3
    ISE330
    EE364
    CSCI104
    4
    CSCI104 3.7
    CSCI109 4.0
    EE364 3.3
    ORIG101 4.0
    
    Expected output
    Data Set 1:
    Student 1
    GPA: 3.67
    CSCI: 3.63
    CENG: 3.53