Easy Beginners Problems > Implementation

Two programmer from Jahangirnagar University made New online judge focussing for beginners. According to their **OJ**(online judge), they added only 10 problems with only 5 different categories. Every categories have different scores. ![enter image description here][1] Their OJ only includes following **fixed** problems. ![enter image description here][2] Their site have **N** users with their respective **Handle**. They solved some problems from this OJ. OJ is still not completed. Ranking system is missing. We know you are good programmer, Can you help her for making Ranking system? **Score of a problem** is the score of it’s category. **Score of a user** is sum of scores of problems that he/she solved. **Rank** of a user X is, (number of users whose score is greater than than X +1). Among two user with same rank, lexicographically smaller user’s handle should be on top. See sample case for more details. **Note**. String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y|, if either |x| > |y| and x1 = y1, x2 = y2, ... , x|y| = y|y|, or exists such number r (r < |x|, r < |y|), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 > yr + 1. Characters in lines are compared like their ASCII codes. Input: ------ First line of input contains a number **N** denoting number of users. Next N lines contains, - First line contains a string(**S**), denoting user’s handle and a integer number **X**, denoting number of problem solved by S. All the user’s handles are **different**. - Next line contains **X** space separated distinct integers denoting the problem number that user S solved. **Constraint**. 1<=N<=110 User’s handle is made up of combination of 1 or more lowercase english letters (‘a’-'z'). Length of user’s handle is no more than 10. 0<=X<=10 Output: ------- Print the user’s handle from rank 1. Sample Input ------------ 4 abc 5 1 2 3 4 5 bcd 5 1 2 3 4 5 salman 2 9 10 baba 0 Sample Output ------------- salman abc bcd baba **Sample clarification.** Score of abc=1+1+3+3+5=13 Score of bcd=1+1+3+3+5=13 Score of salman=8+8=16 Score of baba=0 Score of salman is greater than all others so salman’s rank is 1. Score of abc and bcd is **same**. Both’s rank is 2, but abc should be printed first because abc is lexicographically smaller than bcd. Score of baba is zero and rank is 4. [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/d8c26433-000f-c3e6-a461-08d55cc69b71_b7d6df37d17046faae3b91d619cf018e_W703xH222.png [2]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/24b68814-8b57-c01d-aabc-08d55cc6bf28_a99e6da8830043aaa8d9c83c76b8adf0_W703xH308.png

Bir Bahadur Khatri