#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <climits>
#include <cmath>
#include <numeric>
#include <string>
#include <bitset>
#include <assert.h>
#include <iomanip>
using namespace std;
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
/*
#include <bits/stdc++.h>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define getrand(l, r) uniform_int_distribution<int>(l, r)(rng)
*/
const long long infl = 1e18 + 1;
const int inf = 1e9 + 1;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const long double eps = 1e-7;
const int mod = mod1;
int add(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) { return (a - b + mod) % mod; }
int mul(int a, int b) { return (int)((long long)a * b % mod); }
int pwr(int a, int b = mod - 2)
{
int res = 1;
for(; b > 0; b >>= 1, a = mul(a, a))
if(b & 1)
res = mul(res, a);
return res;
}
template <typename T>
bool chmax(T &a, T b)
{
if(b > a)
{
a = b;
return true;
}
return false;
}
template <typename T>
bool chmin(T &a, T b)
{
if(b < a)
{
a = b;
return true;
}
return false;
}
void solve()
{
priority_queue<tuple<int, int, string, string, int>> pq;
int d, j, g;
cin >> d >> j >> g;
map<string, int> mp;
for(int i = 0; i < j; i++)
{
string s;
cin >> s;
int x;
cin >> x;
mp[s] = x;
}
vector<tuple<int, int, int>> a(g);
for(auto &[f, s, x]: a)
cin >> f >> s >> x;
sort(a.begin(), a.end());
int curr = 0;
long long all = 0;
for(int i = 0; i < d; i++)
{
int n, m;
cin >> n >> m;
for(int j = 0; j < n; j++)
{
string s, t;
cin >> s >> t;
int age;
cin >> age;
int vac = get<2>(a[lower_bound(a.begin(), a.end(), make_tuple(age + 1, -1, -1)) - a.begin() - 1]);
pq.push({vac + mp[t], -curr, s, t, age});
curr++;
}
all += m;
while(not pq.empty() and all--)
{
auto [_, __, ___, ____, _____] = pq.top();
pq.pop();
cout << ___ << ' ' << ____ << ' ' << _____ << '\n';
}
}
cout << "Still unvaccinated people: " << (int)pq.size();
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--)
{
solve();
cout << (t ? "\n" : "");
}
}