#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define all(v) v.begin(),v.end()
#define nl "\n"
#define FIO \
ios_base::sync_with_stdio(false);\
cin.tie(NULL);\
cout.tie(NULL);
class cmp{
public:
bool operator()(pair<pair<pair<ll, ll>, ll>, pair<string, string>>a, pair<pair<pair<ll, ll>, ll>, pair<string, string>>b){
if(a.first.first.first==b.first.first.first){
return a.first.first.second>b.first.first.second;
}
return a.first.first.first<b.first.first.first;
}
};
void solve()
{
ll d, j, g; cin>>d>>j>>g; string s, t; ll r;
map<string, ll> dq;
while(j--){
cin>>s>>r;
dq[s]=r;
}
ll k=1;
vector<pair<pair<ll, ll>, ll>>v;
for(ll i=0;i<g;i++){
ll p, q; cin>>p>>q>>r;
v.push_back({{p, q}, r});
}
map<pair<string, string>, ll>mp;
priority_queue<pair<pair<pair<ll, ll>, ll>, pair<string, string>>, vector<pair<pair<pair<ll, ll>, ll>, pair<string, string>>>, cmp>ff;
while(d--){
ll n, m; cin>>n>>m;
for(ll i=0;i<n;i++)
{
cin>>s>>t>>r;
mp[{s, t}]=r;
ll p=0;
for(ll j=0;j<g;j++)
{
if(v[j].first.first<=r && v[j].first.second>=r){
p=v[j].second;
break;
}
}
ff.push({{{p+dq[t], k}, r}, {s, t}});
k++;
}
for(ll i=0;i<m;i++)
{
if(ff.empty()) break;
s=ff.top().second.first; t=ff.top().second.second;
cout<<s<<" "<<t<<" "<<ff.top().first.second<<nl;
ff.pop();
}
}
cout<<"Still unvaccinated people: "<<ff.size()<<nl;
}
int32_t main()
{
FIO
ll t=1;
// cin>>t;
for(ll i=1;i<=t;i++)
{
// cout<<"Case "<<i<<": ";
solve();
}
}