#include using namespace std; int ac[30] = {}; int l[30]; struct node{ string name; int score[30]; int tot; int t; bool operator < (const node &right) const{ if(tot != right.tot) return tot > right.tot; else return t < right.t; } }; map res; int calc(int n,int m){ return (int)floor(50*n + (50*n)/(0.8 + 0.2*m)); } int main(void){ int n,t; cin >> n; for(int i = 0;i < n;++i){ cin >> l[i]; } cin >> t; for(int i = 0;i < t;++i){ string name; char prob; cin >> name >> prob; if(res.find(name) == res.end()){ node n; n.name = name; fill(n.score, n.score+30,0); n.tot = 0; res[name] = n; } int p = prob - 'A'; ++ac[p]; int score = calc(l[p],ac[p]); node update = res[name]; update.score[p] = score; update.tot += score; update.t = i+1; res[name] = update; } vector < node > rank; for(map::iterator itr = res.begin(); itr != res.end();++itr){ rank.push_back(itr->second); } sort(rank.begin(),rank.end()); for(int i = 0;i < (int)rank.size();++i){ cout << i+1; cout << " " <