matrix = []
line = input().split()
M = int(line[0])
N = int(line[1])
for _ in range(0, M):
for i in input().split():
matrix.append(int(i))
matrix.sort()
for i in range(0, M):
for j in range(0, N):
print(matrix[i*N:i*N+N][j],end=' ')
print()
Comments
Leave a comment