#d2455. 简单分数统计

简单分数统计

Simple Score Statistics

Problem Description

NN friends take part in a Codeforces contest that consists of MM problems, and during the contest there are KK submissions in total on Codeforces.

You know the score of each problem. However, since they can only see the complete submission records during the contest (which also include submissions from other users on other problems, i.e. problems not belonging to this contest), they would like you to write a program to calculate each person's score.

Input Format

The first line contains three integers NN, MM, KK, denoting the number of friends, the number of problems, and the total number of submissions (0<N,M,K≤2000 < N, M, K \le 200).

The next NN lines: the ii-th line contains the id of the ii-th person.

The next MM lines: the jj-th line contains the name and the score of the jj-th problem.

The next KK lines: the kk-th line contains the submitter's id, the problem name, and the result ("WA" or "AC"); an "AC" means passing that problem, and the submitter gets the corresponding score.

Note: both problem names and ids are strings consisting only of English letters and digits; problem scores are positive integers not exceeding 10610^6. Multiple inputs on each line are separated by spaces.

The length of every input string satisfies 0<length≤5000 < \text{length} \le 500.

All user ids and problem names are distinct; once a user gets AC on a problem, they will not submit that problem again; the friends only submit problems that belong to the contest.

Output Format

Output NN lines: the ii-th line outputs the ii-th person's name and corresponding score (separated by a space).

Sample Input

2 2 4
GabrielPessoa
beza
metebronca 100
geometry 200
beza metebronca AC
ffern numbertheory AC
GabrielPessoa geometry WA
beza geometry AC

Sample Output

GabrielPessoa 0
beza 300

Sample Explanation

beza passed metebronca and geometry, scoring 300300.

GabrielPessoa did not pass any problem, so the score is 00.

There are also submissions from other contestants on other problems, which are ignored.