from random import randint
n = int(input())
matrix = [[randint(1, 100) for _ in range(n)] for _ in range(n)]
print('Матрица:')
column = []
for row in range(n):
print(*matrix[row])
column.append(matrix[row][0])
column.sort()
print('\nПервый столбец:')
print(*column)
from random import randint
n = int(input())
matrix = [[randint(1, 100) for _ in range(n)] for _ in range(n)]
print('Матрица:')
column = []
for row in range(n):
print(*matrix[row])
column.append(matrix[row][0])
column.sort()
print('\nПервый столбец:')
print(*column)