FIN = open("frozen.in", "r")
FOUT = open("frozen.out", "w")
ID = FIN.readline().split()
n = int(ID[0])
ID = FIN.readline().split()
rx = 0
ry = 0
rz = 0
ex = 0
ey = 0
ez = 0
bx = 0
by = 0
bz = 0
if (n == 1):
	rx = int(ID[0])
if (n == 2):
	rx = int(ID[0])
	ry = int(ID[1])
if (n == 3):
	rx = int(ID[0])
	ry = int(ID[1])
	rz = int(ID[2])
ID = FIN.readline().split()
if (n == 1):
	bx = int(ID[0])
	ex = int(ID[1])
if (n == 2):
	bx = int(ID[0])
	by = int(ID[1])
	ex = int(ID[2])
	ey = int(ID[3])
if (n == 3):
	bx = int(ID[0])
	by = int(ID[1])
	bz = int(ID[2])
	ex = int(ID[3])
	ey = int(ID[4])
	ez = int(ID[5])
print(bx, ex)
up = 0
down = 0
left = 0
right = 0
forw = 0
back = 0
def check():
	
	res = 0
	global up
	global down
	global back
	global forw
	global left
	global right
	IPONB(ex, ey, ez, ex, by, bz)
	IPONB(ex, ey, ez, bx, ey, bz)
	IPONB(ex, ey, ez, bx, by, ez)
	IPONB(bx, by, bz, bx, ey, ez)
	IPONB(bx, by, bz, ex, by, ez)
	IPONB(bx, by, bz, ex, ey, bz)
	print(up+down+left+right+back+forw)
	return up+down+left+right+back+forw
def IPONB(a,b,c,d,e,f):
	print(a,b,c,d,e,f)
	global up
	global down
	global back
	global forw
	global left
	global right
	print(up, down, back, forw, left, right)
	if (a == d == 0):
		up = 1
	if (a == d == rx):
		down = 1
	
	if (b == e == 0):
		left = 1
	if (b == e == ry):
		right = 1

	if (c == f == 0):
		forw = 1
	if (c == f == rz):
		back = 1
print(6 - check() ,file = FOUT)
FIN.close()
FOUT.close()
	
	
	