#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector level(n); REP (i, n) cin >> level[i]; int t; cin >> t; vector > acs(n); map sum; map > scores; map submission; REP (i, t) { string name; char p; cin >> name >> p; int j = p - 'A'; acs[j].push_back(name); sum[name] += 50 * level[j]; if (!scores[name].size()) { scores[name].resize(n); } scores[name][j] += 50 * level[j]; submission[name] = i; } REP (i, n) { REP (j, acs[i].size()) { sum[acs[i][j]] += 250 * level[i] / (5 + j); scores[acs[i][j]][i] += 250 * level[i] / (5 + j); } } vector > v; for (auto &[name, points]: sum) { v.emplace_back(-points, submission[name], name); } sort(v.begin(), v.end()); REP (i, v.size()) { long long x; int y; string z; tie(x, y, z) = v[i]; cout << (i+1) << " " << z << " "; REP (j, n) cout << scores[z][j] << " "; cout << sum[z] << endl; } return 0; }