#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define bug(a) cout << #a << " : " << a << endl;
void solve(){
int d, j, g; cin >> d >> j >> g;
map<string,int> jobs;
for(int i = 1;i <= j; i++){
string s; cin >> s;
int x; cin >> x;
jobs[s] = x;
}
int arr[130] = {0};
for(int i = 1; i <= g; i++){
int l, r, x; cin >> l >> r >> x;
for(int j = l; j <= r; j++){
arr[j] = x;
}
}
priority_queue< pair<int, pair<int, pair<int, pair<string,string> > >> > pq;
int idx = 1;
int vaci = 0;
for(int i = 1; i <= d; i++){
int n, m; cin >> n >> m;
vaci += m;
for(int j = 1; j <= n; j++){
string name, job;
int age;
cin >> name >> job >> age;
int pr = arr[age];
if ( jobs.find(job) != jobs.end() ) {
pr += jobs[job];
}
pq.push({pr,{-idx,{age, {name, job}}}});
idx++;
}
int cnt = 0;
while ( !pq.empty() and vaci ) {
auto x = pq.top();
pq.pop();
cout << x.second.second.second.first << ' ' << x.second.second.second.second << ' ' << x.second.second.first << '\n';
vaci--;
}
}
int baki = pq.size();
cout << "Still unvaccinated people: " << baki << '\n';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc = 1, cs = 0;
// cin >> tc;
while(tc--){
//cout << "Case # " << ++cs << ": " ;
solve();
}
}