Skip to content
UPEEC

Rank the Students

Easy#sorting#custom-comparator· solved by 0 · time limit 2.0 s

Sort students by marks, highest first. Students with equal marks are listed in alphabetical order of name.

Input

nn, then nn lines name marks (names are unique lowercase words).

Output

The sorted list, name marks per line.

Constraints

1≤n≤1051 \le n \le 10^5, 0≤0 \le marks ≤100\le 100

Sample 1

Input

4
riya 90
aman 85
zoya 90
kabir 85

Output

riya 90
zoya 90
aman 85
kabir 85

Sign in or join free to run and submit your solution.