#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define bug(a) cout<<#a<<" : "<<a<<endl;
#define bug2(a,b) cout<<#a<<" : "<<a<<"\t"<<#b<<" : "<<b<<endl;
struct node{
string n,j;
int a,x,y;
};
bool cmp(node f,node g)
{
if(f.x==g.x)return f.y<g.y;
return f.x>g.x;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
while(t--){
int d,j,g;
cin>>d>>j>>g;
map<string,int> mp;
map<int,int>mp1;
while(j--)
{
string s;
int x;
cin>>s>>x;
mp[s]=x;
}
while(g--)
{
int a,b,c;
cin>>a>>b>>c;
for(int i=a; i<=b; i++)
{
mp1[i]=c;
}
}
map<int,int> mp4;
vector<node> v;
int num=0,vac=0;
j=0;
while(d--)
{
int n,m;
cin>>n>>m;
num += n;
vac += m;
while(n--){
string a,b;
int c;
cin>>a>>b>>c;
int z=mp[b]+mp1[c];
mp4[z]++;
node temp;
temp.n=a;
temp.j=b;
temp.a=c;
temp.x=z;
temp.y=mp4[z];
v.push_back(temp);
}
sort(v.begin()+j,v.end(),cmp);
while(m-- && j<v.size()){
cout<<v[j].n<<" "<<v[j].j<<" "<<v[j].a<<endl;
j++;
}
}
num -= vac;
if(num<0)num=0;
cout<<"Still unvaccinated people: "<<num<<endl;
}
return 0;
}