#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;
while(d--) {
int n, m; cin >> n >> m;
while(n--){
string s, t; int age;
cin >> s >> t >> age;
int cur = a[t];
auto lbid = upper_bound(rng.begin(), rng.end(), make_pair(age, (int)-2e9)) - rng.begin();
// cout << lbid << " ";
if(lbid != 0){
lbid--;
if(rng[lbid].first <= age and rng[lbid].second>=age){
cur += rngPrio[{rng[lbid].first, rng[lbid].second}];
}
// cout << cur << endl;
}
string tot = s + " " + t + " " + to_string(age);
// string tot = "";
li.insert({cur, -id});
ids.push_back(tot);
id++;
}
// for(auto [xx,xxx,xxxx]: li) cerr << xx << " " << xxx << " " << xxxx << endl;
// cerr << endl;
m += xta;
while(m and (int)li.size()){
auto [Pro, id] = *li.rbegin();
li.erase(li.find(*li.rbegin()));
cout << ids[-id-1] << nl;
m--;
// cout << endl;
// cout << endl;
}
xta = m;
}
cout << "Still unvaccinated people: " << (int)li.size() << 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;
}