1 #include <stdio.h>
2 #include <algorithm>
3 #include <iostream>
4 #include <string.h>
5 #include <string>
6 #include <math.h>
7 #include <stdlib.h>
8 #include <queue>
9 #include <stack>
10 #include <set>
11 #include <map>
12 #include <list>
13 #include <iomanip>
14 #include <vector>
15 #pragma comment(linker, "/STACK:1024000000,1024000000")
16 #pragma warning(disable:4786)
17
18 using namespace std;
19
20 const int INF = 0x3f3f3f3f;
21 const int MAX = 1000 + 10;
22 const double eps = 1e-8;
23 const double PI = acos(-1.0);
24
25 struct T
26 {
27 int time , id;
28 char a , s[5];
29 }p[1001];
30
31 struct T1
32 {
33 int time , id;
34 }f[15];
35
36 int main()
37 {
38 int n , t , m , i , l , ll , maxn = 0 , ff[105][15];
39 scanf("%d %d %d",&n , &t , &m);
40 memset(ff , 0 , sizeof(ff));
41 for(i = 1;i <= n;i ++)
42 f[i].time = -1;
43 for(i = 0;i < m;i ++)
44 {
45 scanf("%d %d %c %s",&p[i].time , &p[i].id , &p[i].a , p[i].s);
46 l = p[i].a - 'A' + 1;
47 ll = p[i].id;
48 if(l > maxn)
49 maxn = l;
50 if(strcmp(p[i].s , "Yes") == 0)
51 {
52 ff[ll][l] ++;
53 if(ff[ll][l] == 1 && p[i].time >= f[l].time)
54 {
55 f[l].time = p[i].time;
56 f[l].id = p[i].id;
57 }
58 ff[ll][l] ++;
59 }
60 }
61 for(i = 1;i <= maxn;i ++)
62 {
63 if(f[i].time == -1)
64 printf("%c - -\n",i - 1 + 'A');
65 else
66 printf("%c %d %d\n", i - 1 + 'A' , f[i].time , f[i].id);
67 }
68 return 0;
69 }