import sys n, order = int(input()), input() dic = dict() for i in range(n): inf = input().split(' ') dic[inf[0] + str(i).zfill(3)] = int(inf[1]) if order == '0': for i in sorted(dic.items(), key = lambda x : x[1], reverse = True): print(i[0][:-3] + ' ' + str(i[1])) else: f...