#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ll long long
#define int long long
#define pii pair<int, int>
void solve(){
int d,j,g; cin >> d >> j >>g;
// prio, -id, name
map<string, int> a;
for(int i=0;i<j;++i) {
string s; int p;
cin >> s >> p;
a[s] = p;
}
vector<pii> rng;
map<pii, int> rngPrio;
while(g--) {
int l,r,p; cin >> l >> r >> p;
rng.push_back(make_pair(l,r));
rngPrio[{l, r}] = p;
}
sort(rng.begin(), rng.end());
// for(auto [p, q]: rngPrio) cout << p.first << " " << p.second << " " << q << endl;
// int q; cin >> q;
// int id = 0;
// prio, id, name
set<pair<int, int>> li;
vector<string> ids;
int id = 1;
int xta = 0;
map<int, queue<int>> mp;
while(d--) {
int n, m; cin >> n >> m;
while(n--){
string s, t; int age;
cin >> s >> t >> age;
int cur = a[t];
int pqr = 0;
for(int i=0;i<rng.size();++i) {
if(age>=rng[i].first and age <= rng[i].second){
cur += rngPrio[{rng[i].first, rng[i].second}];
pqr++;
}
assert(pqr<2);
}
string tot = s + " " + t + " " + to_string(age);
// string tot = "";
// cout << tot << endl;
// li.insert({cur, -id});
mp[cur].push(id);
ids.push_back(tot);
id++;
}
// for(auto [xx,xxx,xxxx]: li) cerr << xx << " " << xxx << " " << xxxx << endl;
// cerr << endl;
while(m and (int)mp.size()){
// auto [Pro, id] = *li.rbegin();
// li.erase(li.find(*li.rbegin()));
auto it = mp.rbegin();
int nn = it->second.front();
it->second.pop();
if(it->second.empty()) mp.erase(it->first);
cout << ids[nn-1] << nl;
m--;
// cout << endl;
// cout << endl;
}
}
int ss = 0;
for(auto xxx : mp){
ss += xxx.second.size();
}
cout << "Still unvaccinated people: " << ss << nl;
}
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1, tc = 0;
// cin >> t ;
while(t--){
// cout << "Case " << ++tc << ": ";
solve();
}
return 0;
}