import random
n = int(input('Введите кол-во столбцов матрицы: '))
m = int(input('Введите кол-во строк матрицы: '))
matrix = [[random.randrange(0, 10) for y in range(n)] for x in range(m)]
print(matrix)
max_x = 0
for i in range(n):
for j in range(m):
if max_x < matrix[i].count(matrix[i][j]):
print(matrix.index(matrix[i]))
max_x = matrix[i].count(matrix[i][j])
else:
break
import random
from collections import Counter
n = 5
m = 5
matrix = [[random.randrange(0, 10) for y in range(n)] for x in range(m)]
print(*matrix, sep='\n')
most_common = [(i, Counter(x).most_common(1)[0]) for i, x in enumerate(matrix, start=1)]
print('(row_number, (element, count))')
print(*sorted(most_common, key=lambda x: int(x[1][1]), reverse=True), sep='\n')