/**
* author: Binoy Barman
* created: 2024-12-10 16:11:18
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long
struct Person {
string name, job;
int age, pry;
Person(string _name, string _job, int _age, int _pry) {
name = _name;
job = _job;
age = _age;
pry = _pry;
}
};
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int d, j, g;
cin >> d >> j >> g;
map<string, int> job;
for (int i = 0; i < j; i++) {
string w;
int p;
cin >> w >> p;
job[w] = p;
}
vector<int> age(500001, 0);
for (int i = 0; i < g; i++) {
int l, u, p;
cin >> l >> u >> p;
for (int i = l; i <= u; i++) age[i] = p;
}
vector<Person> q;
int vac = 0;
while(d--) {
int n, m;
cin >> n >> m;
vac += m;
for (int i = 0; i < n; i++) {
string nam, w; int ag;
cin >> nam >> w >> ag;
int priority = job[w] + age[ag];
q.push_back(Person(nam, w, ag, priority));
}
}
sort(all(q), [&](Person p1, Person p2) {
return p1.pry > p2.pry;
});
int id = 0;
while(id < q.size() && vac != 0) {
Person v = q[id];
id++;
vac--;
cout << v.name << " " << v.job << " " << v.age << nl;
}
cout << "Still unvaccinated people: " << q.size() - id << nl;
return 0;
}