#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using o_set = tree<T, null_type, std::less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
struct st {
int age;
string name, job;
};
void solve() {
int d, j, g;
cin >> d >> j >> g;
map<string, int> jobP;
for (int i = 0; i < j; i++) {
string s;
int p;
cin >> s >> p;
jobP[s] = p;
}
vector<pair<pair<int, int>, int>> ageP(g);
for (int i = 0; i < g; i++) {
int l, r, p;
cin >> l >> r >> p;
ageP[i] = {{l, r}, p};
}
int curVac = 0, taken = 0, tot = 0;
priority_queue<int> pq;
//multiset<st, cmp()> ms;
map<int, queue<st>> mp;
for (int i = 1; i <= d; i++) {
int n, vac;
cin >> n >> vac;
curVac += vac;
tot += n;
for (int k = 1; k <= n; k++) {
string name, job;
int age, p = 0;
cin >> name >> job >> age;
for (int kk = 0; kk < g; kk++) {
if(ageP[kk].first.first <= age and ageP[kk].first.second >= age) {
p = ageP[kk].second;
break;
}
}
pq.push(p + jobP[job]);
//cout << p + jobP[job] << '\n';
st vari;
vari.name = name;
vari.job = job;
vari.age = age;
mp[p + jobP[job]].push(vari);
}
while(!pq.empty() and curVac) {
int tp = pq.top();
//while(mp[tp])
//if(!curVac and !mp[tp].empty())
st ans = mp[tp].front();
cout << ans.name << " " << ans.job << " " << ans.age << '\n';
mp[tp].pop();
pq.pop();
curVac--;
taken++;
}
}
cout << "Still unvaccinated people: " << tot - taken << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin>>t;
for(int tc = 1; tc <= t; tc++) {
// cout<<"Case "<<tc<<":";
solve();
}
}