#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll day, job, G, mx = 1e10 + 5;
map<string, ll> jobpriority;
pair<pair<ll, ll>, ll> A[10];
void solve() {
cin >> day >> job >> G;
for (ll i = 0; i < job; i++) {
string s; cin >> s;
ll d; cin >> d;
jobpriority[s] = d;
}
for (ll i = 0; i < G; i++) {
ll x, y, z; cin >> x >> y >> z;
A[i] = {{x, y}, z};
}
priority_queue<pair<ll, pair<ll, pair<ll, pair<string, string>>>>> q;
ll vac = 0;
while (day--) {
ll el, got; cin >> el >> got;
vac += got;
while (el--) {
string name, oc; ll age; cin >> name >> oc >> age;
ll sc = jobpriority[oc];
for (ll i = 0; i < G; i++) {
if (age >= A[i].first.first && age <= A[i].first.second) {
sc += A[i].second;
break;
}
}
q.push({sc, {mx--, {age, {name, oc}}}});
}
while (!q.empty() && vac) {
pair<ll, pair<ll, pair<ll, pair<string, string>>>> now = q.top();
q.pop();
cout << now.second.second.second.first << " " << now.second.second.second.second << " " << now.second.second.first << endl;
vac -= 1;
}
}
cout << "Still unvaccinated people: " << q.size() << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int tt = 1;
// cin >> tt;
while (tt--) {
solve();
}
return 0;
}