#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define inf 1013161010
#define mod 1000000007
#define mod1 998244353
#define ll long long
#define lf long double
#define sz(x) ((int)x.size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,a,b) for(ll i=a;i<=b;i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;
ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){ stringstream ss; ss<< number; return ss.str();}
const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;
ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
ll fast_pow(ll a,ll m, ll mode) { if(m==0) return 1; else if(m==1) return a; ll h=fast_pow(a,m/2,mode); if(m%2==0) return ((h*h)%mode); else return ((((h*h)%mode)*a)%mode);}
ll mmi(ll b, ll mode){return fast_pow(b, mode-2, mode);}
struct Person {
int priority;
string name;
string job;
int age;
Person(int p, string n, string j, int a) : priority(p), name(n), job(j), age(a) {}
bool operator<(const Person& other) const {
return priority < other.priority;
}
};
int main() {
int t = 1;
// cin >> t;
while (t--) {
ll n=0, j, g, d, l, u, p, x, r, age, m;
cin >> d >> j >> g;
string job, name;
vector<pair<pair<int, int>, int> > groups;
unordered_map<string, int> mp;
rep(i, j) {
cin >> job >> p;
mp[job] = p;
}
rep(i, g) {
cin >> l >> u >> p;
groups.pb({{l, u}, p});
}
priority_queue<Person> pq;
int total = 0;
rep(i, d) {
cin >> n >> m;
total += m;
rep(j, n) {
cin >> name >> job >> age;
int priority = 0;
if (mp.find(job) != mp.end()) {
priority += mp[job];
}
rep(k, g) {
if (age >= groups[k].ff.ff and age <= groups[k].ff.ss) {
priority += groups[k].ss;
}
}
// cout << priority << endl;
pq.push(Person(priority, name, job, age));
}
while(!pq.empty()) {
if (total == 0) {
break;
}
Person person = pq.top();
pq.pop();
cout << person.name << " " << person.job << " " << person.age << endl;
total--;
}
}
cout << "Still unvaccinated people: " << sz(pq) << endl;
}
return 0;
}