#include "iostream" using namespace std; int N, T; int dif[26]; int solved[26]; char name_box[20]; char num; char name[4000][20]; int score[4000][26]; int sum[4000]; int last[4000]; int fig; bool flag; bool same; int ranking[4000]; int box; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> dif[i]; } cin >> T; for (int i = 0; i < T; i++) { ranking[i] = i; } for (int j = 0; j < T; j++) { cin >> name_box >> num; solved[num-'A'] ++; flag = true; for (int i = 0; i < fig; i++) { same = true; for (int k = 0; k < 20; k++) { if (name_box[k] != name[i][k]) { same = false; break; } } if (same) { score[i][num - 'A'] = 50 * dif[num - 'A'] + (double)(50 * dif[num - 'A']) / (0.8 + 0.2*(double)solved[num - 'A']); last[i] = j; flag = false; } } if (flag) { for (int k = 0; k < 20; k++) { name[fig][k] = name_box[k]; } score[fig][num - 'A'] = 50 * dif[num - 'A'] + (double)(50 * dif[num - 'A']) / (0.8 + 0.2*(double)solved[num - 'A']); last[fig] = j; fig++; } } for(int i = 0; i < fig; i++) { for (int j = 0; j < N; j++) { sum[i] += score[i][j]; } } for (int i = 0; i < fig; i++) { for (int j = i + 1; j < fig; j++) { if (sum[i] < sum[j]||(sum[i]==sum[j]&&last[i]>last[j])) { box = sum[i]; sum[i] = sum[j]; sum[j] = box; box = last[i]; last[i] = last[j]; last[j] = box; box = ranking[i]; ranking[i] = ranking[j]; ranking[j] = box; } } } for (int i = 0; i < fig; i++) { cout << i+1 << " "<< name[ranking[i]] << " "; for (int j = 0; j < N; j++) { cout << score[ranking[i]][j] << " "; } cout << sum[i] << "\n"; } return 0; }