#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 42
#endif
map<string, ll> mp;
map<ll, pair<ll, ll>> mp1;
struct A {
string name, job;
ll age;
A(string name, string job, ll age)
: name{name}, job{job}, age{age} {
}
ll get_priority() {
ll v = 0;
if (mp.contains(job))
v += mp[job];
auto itr = mp1.lower_bound(age);
if (itr != mp1.end() && itr->second.first <= age)
v += itr->second.second;
return v;
}
};
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll d, j, g;
cin >> d >> j >> g;
for (ll i = 0; i < j; i++) {
string job;
ll v;
cin >> job >> v;
mp[job] = v;
}
for (ll i = 0; i < g; i++) {
ll l, r, p;
cin >> l >> r >> p;
mp1[r] = {l, p};
}
function<bool(tuple<ll, ll, A>, tuple<ll, ll, A>)> comparator = [](const tuple<ll, ll, A> &t1, const tuple<ll, ll, A> &t2) -> bool {
ll p1 = get<0>(t1), p2 = get<0>(t2);
ll idx1 = get<1>(t1), idx2 = get<1>(t2);
if (p1 != p2)
return p1 < p2;
return idx1 > idx2;
};
priority_queue<tuple<ll, ll, A>, vector<tuple<ll, ll, A>>, decltype(comparator)> pq(comparator);
ll cnt = 0;
for (ll i = 0; i < d; i++) {
ll n, m;
cin >> n >> m;
for (ll i = 0; i < n; i++) {
string name, job;
ll age;
cin >> name >> job >> age;
A a(name, job, age);
pq.push({a.get_priority(), cnt++, a});
}
for (ll i = 0; i < m; i++) {
if (pq.empty())
continue;
A a = get<2>(pq.top());
pq.pop();
cout << a.name << ' ' << a.job << ' ' << a.age << '\n';
}
}
cout << "Still unvaccinated people: " << pq.size() << '\n';
}