#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tc=1,tc1=1;
//cin>>tc;
up:
while(tc--){
ll D,J,G;
cin>>D>>J>>G;
map<string,ll>mp;
for(ll i=0;i<J;i++){
string s;
ll val;
cin>>s>>val;
mp[s]=val;
}
map<ll,ll>mp1;
for(ll i=0;i<G;i++){
ll l,r,p;
cin>>l>>r>>p;
for(ll j=l;j<=r;j++){
mp1[j]=p;
}
}
ll avail=0,c=0;
vector<string>nam,pr;
vector<ll>ag;
set<pair<ll,ll>>sp;
vector<ll>ans;
for(ll i=0;i<D;i++){
ll n,m;
cin>>n>>m;
for(ll j=0;j<n;j++){
string s,t;
ll age;
cin>>s>>t>>age;
nam.push_back(s),pr.push_back(t),ag.push_back(age);
sp.insert({-mp[t]-mp1[age],c++});
}
avail+=m;
while(1){
if(sp.size()==0||avail==0){
break;
}
auto[name,in]=*sp.begin();
ans.push_back(in);
sp.erase({name,in});
avail--;
}
}
for(auto i:ans){
cout<<nam[i]<<" "<<pr[i]<<" "<<ag[i]<<'\n';
}
ll sz=ans.size();
cout<<"Still unvaccinated people: "<<c-sz<<'\n';
}
}