задача 1332

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
n = int(input())
adj_matrix = []
for i in range(n):
a = [int(s) for s in input().split()]
adj_matrix.append(a)
for k in range(n):
for i in range(n):
for j in range(n):
if adj_matrix[i][k] == 1 and adj_matrix[k][j] == 1:
adj_matrix[i][j] = 1
for elem in adj_matrix:
for e in elem:
print(e, end = ' ')
print()