#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std ;
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>;
#define int long long
#define opt() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+10 ;
const int mod= 1e9+7 ;
#define pb push_back
#define mp make_pair
bool cmp(pair<int ,int>a,pair<int,int>b){
if(a.first>b.first)return true;
else if(a.first==b.first)
{
return a.second<b.second;
}
return false;
}
int32_t main()
{
opt();
int tt=1;
//cin>>tt;
for(int tc=1; tc<=tt; tc++)
{
int d,j,g;
cin>>d>>j>>g;
map<string,int>job;
for(int i=0;i<j;i++)
{
string s;
cin>>s;
int pr;
cin>>pr;
job[s]=pr;
}
vector<int>age(126);
for(int i=0;i<g;i++)
{
int l,r,val;
cin>>l>>r>>val;
for(int i=l;i<=r;i++)age[i]=val;
}
map<string,int>name;
vector<pair<string,int>>vec;
map<string,int>nmbr;
map<int,string>inv;
vector<pair<int,int>>vect;
int totalVac=0;
int jj=1;
int tn=0;
for(int i=0;i<d;i++)
{
int n,m;
cin>>n>>m;
tn+=n;
totalVac+=m;
for(int i=0;i<n;i++)
{
string a,b;
cin>>a>>b;
string con=a;
con+=" ";
con+=b;
int x;
cin>>x;
string y=to_string(x);
con+=" ";
con+=y;
name[con]=job[b]+age[x];
vec.pb({con,name[con]});
nmbr[con]=jj;
inv[jj]=con;
vect.pb({name[con],jj});
jj++;
}
}
sort(vect.begin(),vect.end(),cmp);
// for(int i=0;i<vect.size();i++)
// {
// cout<<vect[i].first<<" "<<vect[i].second<<endl;
// }
vector<string>ans1;
for(int i=0;i<totalVac;i++)
{
cout<<inv[vect[i].second]<<endl;
}
cout<<"Still unvaccinated people: "<<tn-totalVac<<endl;
}
return 0;
}