#include using namespace std; signed main(){ int N; cin >> N; vector< int > L( N ); for( int i = 0; i < N; ++i ) cin >> L[ i ]; int T; cin >> T; vector< int > p_ac_cnt( N ); map< string, int > scr; map< string, map< int, int > > scr_breakdown; map< string, int > last_sub; for( int i = 0; i < T; ++i ){ string name; string p; cin >> name >> p; int P = p[ 0 ]; int pnt = 50 * L[ P - 'A' ] + ( 50 * L[ P - 'A' ] ) / ( 0.8 + 0.2 * ++p_ac_cnt[ P - 'A' ] ); scr_breakdown[ name ][ P - 'A' ] = pnt; scr[ name ] += pnt; last_sub[ name ] = i; } priority_queue< tuple< int, int, string > > pq; for( auto it = scr.begin(); it != scr.end(); ++it ) pq.emplace( scr[ it->first ], -last_sub[ it->first ], it->first ); for( int rank = 1; not pq.empty(); ++rank ){ cout << rank << " "; string name = get< 2 >( pq.top() ); pq.pop(); cout << name << " "; for( int i = 0; i < N; ++i ) cout << scr_breakdown[ name ][ i ] << " "; cout << scr[ name ] << endl; } return 0; }