#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define MOD 1000000007
#define vll vector<ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mem(a,b) memset(a, b, sizeof(a))
#define co(n) cout << n << endl
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr(x, n) for (int i = x; i < n; ++i)
#define fraction(x) cout << fixed << setprecision(x)
#define Baba_Yaga ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
const double eps = 1e-9;
const int N = 2e5+123;
ll gcd(ll a,ll b) { return __gcd(a,b); }
ll lcm(ll a,ll b) { return (a*b)/__gcd(a,b); }
int dx[] = {0, 0, +1, -1, +1, +1, -1, -1};
int dy[] = {+1, -1, 0, 0, +1, -1, +1, -1};
bool compare(const pair<ll, string> &a, const pair<ll, string> &b)
{
return a.first < b.first;
}
void solve()
{
ll d, j, g; cin >> d >> j >> g;
map<string, ll> job;
for(int i=1; i<=j; i++)
{
string s; ll k; cin >> s >> k;
job[s] = k;
}
vll age(130);
for(int i=1; i<=g; i++)
{
ll l, r, k; cin >> l >> r >> k;
for(int j=l; j<=r; j++)
{
age[j] = k;
}
}
map<string, string> profession;
map<string, ll> person_age;
priority_queue<pair<ll, string>, vector<pair<ll, string>>, decltype(&compare)> pq(compare);
ll vaccine = 0;
for(int i=1; i<=d; i++)
{
ll n, m; cin >> n >> m;
vaccine += m;
while(n--)
{
ll aag;
string nm, prf;
cin >> nm >> prf;
cin >> aag;
profession[nm] = prf;
person_age[nm] = aag;
ll prio_point = (age[aag] + job[prf]);
pq.push({prio_point, nm});
}
while(vaccine >= 1 && (!pq.empty()))
{
string namee = pq.top().second;
string prr = profession[namee];
ll age = person_age[namee];
cout << namee << " " << prr << " " << age << endl;
pq.pop();
vaccine--;
}
}
cout << "Still unvaccinated people: " << pq.size() << endl;
}
// --- Think the problem backwards ---
int main()
{
Baba_Yaga;
ll tc = 1; //cin >> tc;
while(tc--) solve();
}