# задача 1332

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64``` ```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() ''' n = int(input()) graph = [list(map(int, input().split())) for i in range(n)] for k in range(n): for i in range(n): for j in range(n): if graph[i][k] and graph[k][j]: graph[i][j] = 1 for i in graph: print(*i) ''' ''' import copy class Matrix_Graph(): def __init__(self, V): self.V = V self.matrix = [] self.E = 0 for i in range(self.V): self.matrix += [list(map(int, input().split()))] for i in range(self.V): self.E += len(list(self.neighbours(i))) self.E //= 2 self.transgraph = copy.deepcopy(self.matrix) def neighbours(self, v): neighbours = [] for j in range(self.V): if self.matrix[v][j] == 1: neighbours += [j] return neighbours def oriented_transivity(self): for k in range(self.V): for i in range(self.V): for j in range(self.V): if self.transgraph[i][k] + self.transgraph[k][j] == 2: self.transgraph[i][j] = 1 return self.transgraph transgraph = Matrix_Graph(int(input())).oriented_transivity() for i in range(len(transgraph)): print(" ".join(list(map(str, transgraph[i])))) ''' ```