unite = lambda a : [j for i in a for j in i]

def intersperse(a, b):
	assert len(a) == len(b)
	return unite(zip(a, b))

def rotate(a):
	n = len(a)
	return [\
		(\
			intersperse(\
				[a[n - j - 1][2 * i - 2 * j] for j in range(i)],\
				[a[n - j - 1][2 * i - 2 * j - 1] for j in range(i)]\
			) + [a[n - i - 1][0]]\
		)\
		for i in range(n) \
	]

with open('triangle.in') as IN:
	a = [IN.readline().split() for i in range(int(IN.readline()))]
	with open('triangle.out', 'w') as OUT:
		for i in range(2):
			a = rotate(a)
			OUT.write('\n'.join(' '.join(s) for s in a) + '\n')
		
