from __future__ import print_function
from sys import stdin

def printf(str, *args):
	print(str % args, end='')

MAXITEM = 10
m = [[0 for col in range(MAXITEM)] for row in range(MAXITEM)]

printf("입력으로 넣을 관계 행렬의 행의 크기는?\n")
maxvalue = input_enter(1)
printf("\n")
printf("1과 0으로 데이터를 입력하세요.?\n")

list = []
while len(list) < maxvalue*maxvalue:
	list += stdin.readline().split()

for i in range(1, maxvalue+1):
	for j in range(1, maxvalue+1):
		m[i][j] = int(list[(i-1)*maxvalue + (j-1)])
printf("\n")

for i in range(1, maxvalue+1):
	for j in range(1, maxvalue+1):
		if m[i][j] == 1:
			for x in range(1, maxvalue+1):
				if m[j][x] ==1:
					for y in range(1, maxvalue+1):
						if m[x][y] == 1:
							printf("(%2d%2d%2d%2d) => (%d..%d)\n" %(i,j,x,y,i,y))

stdin.readline()
