#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define f(i,s,n) for(int i = s; i < n; i++)
#define int long long
bool cmp(pair<int, int> p1, pair<int, int> p2){
if(p1.first != p2.first)return p1.first > p2.first;
return p1.second < p2.second;
}
void solve(){
int d,j,g;cin>>d>>j>>g;
int vacPainai = 0;
map<string, int> mp;
vector<int> agePrio(126, 0);
f(i,0,j){
string s;int p;
cin>>s;cin>>p;
mp[s] = p;
}
f(i,0,g){
int l,u,p;cin>>l>>u>>p;
for(int i = l; i <= u; i++)agePrio[i] = p;
}
int m = 0, n = 0;
priority_queue<pair<int, int> > pq;
vector<pair<pair<string, string>, int> > v;
while(d--){
// cout<<"ddd"<<nl;
int tmpn,tmpm;cin>>tmpn>>tmpm;
m += tmpm;
for(int i = 0; i < tmpn; i++){
int prio = 0;
string nm, jb;int age;
cin>>nm>>jb;cin>>age;
prio = mp[jb] + agePrio[age];
// cout<<nm<<" "<<mp[jb]<<" "<<agePrio[age]<<nl;
v.push_back({{nm, jb}, age});
pq.push({prio, -1 * (v.size() - 1)});
// cout<<v.size()<<nl;
}
// while(!pq.empty() && m > 0) {
// pair<int,int> tp = pq.top();
// pq.pop();
// // cout<<tp.first<<" "<<v[-tp.second].first.first<<" "<<tp.second<<nl;
// m--;
// }
// cout<<nl;
while(!pq.empty() && m > 0) {
pair<int,int> tp = pq.top();
pq.pop();
// cout<<tp.second<<nl;
string nm = v[-tp.second].first.first;
string jb = v[-tp.second].first.second;
int age = v[-tp.second].second;
cout<<nm<<" "<<jb<<" "<<age<<nl;
m--;
}
n = v.size();
}
cout<<"Still unvaccinated people: "<<pq.size()<<nl;
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int T = 1;
// cin>>T;
for(int tc = 1; tc <= T; tc++){
solve();
}
}