#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
struct id {
string name, job;
int age;
id(string name_, string job_, int age_) {
name = name_; job = job_; age = age_;
}
};
void solve() {
int D, J, G; cin >> D >> J >> G;
map<string, int> job;
for (int i = 0; i < J; i++) {
string name; cin >> name;
int p; cin >> p;
job[name] += p;
}
vector<array<int, 2>> age;
for (int i = 0; i < G; i++) {
int l, r, p; cin >> l >> r >> p;
age.push_back({l, p});
}
sort(age.begin(), age.end());
vector<id> entry;
multiset<array<int, 2>> rem;
int vac = 0;
for (int it = 0; it < D; it++) {
int n, m; cin >> n >> m;
vac += m;
for (int i = 0; i < n; i++) {
string name, job_name;
cin >> name;
cin >> job_name;
int cur_age; cin >> cur_age;
// cout << name << " " << job_name << " " << cur_age << '\n';
int priority = job[job_name];
for (int j = age.size() - 1; j >= 0; j--) {
if (age[j][0] <= cur_age) {
priority += age[j][1]; break;
}
}
rem.insert(array<int, 2>{-priority, int(entry.size())});
entry.push_back(id(name, job_name, cur_age));
}
while (!rem.empty() && vac > 0) {
vac -= 1;
auto f = *rem.begin();
rem.erase(rem.begin());
int _id = f[1];
cout << entry[_id].name << " " << entry[_id].job << " " << entry[_id].age << '\n';
}
}
cout << "Still unvaccinated people: " << rem.size() << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
// cin >> tt;
for(int t = 1; t <= tt; t++) {
solve();
}
}