Written By : MathModel
Just implement what's written , the knowledge you need is how to use comparators with sortings (AKA lambads) , Also you need to take care of input stream errors since the count is not defined.
a = []
while True:
try:
s=input()
if not s.strip():
break
x,y=map(int,s.split())
a.append([x,y])
except EOFError:
break
a.sort(key=lambda p:(p[0],-p[1]))
for i in a:
print(*i)