登录之后查看代码,点此登录账号
from collections import defaultdict
while True:
try:
n, m = list(map(int, input().split()))
numlist = input().split() # n elements, each elements of length m
counter = [defaultdict(int) for _ in range(m)]
for num in numlist:
for i in range(m):
counter[i][num[i]] += 1
counter = counter[::-1]
for cnt in counter:
cnt = sorted(cnt.items(), key = lambda x:(x[1], -int(x[0])), reverse = True)
print(cnt[0][0])
except Exception as e:
#print(e)
break