During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.

It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.

To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.

Cube is called solved if for each face of cube all squares on it has the same color.

<a>https://en.wikipedia.org/wiki/Rubik's_Cube</a>
In first line given a sequence of 24 integers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 6), where *a*<sub class="lower-index">*i*</sub> denotes color of *i*-th square. There are exactly 4 occurrences of all colors in this sequence.
In first test case cube looks like this:

In second test case cube looks like this: 

It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
NO
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
YES
2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1
NO
3 4 2 3 5 5 6 6 4 5 4 6 5 1 1 1 6 2 1 3 3 2 4 2
NO
5 5 2 5 3 3 2 6 6 4 2 4 6 1 4 3 1 6 2 1 3 4 5 1
NO
6 6 1 2 6 1 1 3 5 4 3 4 3 5 5 2 4 4 6 2 1 5 3 2
NO
2 2 1 1 5 5 5 5 3 3 4 4 1 4 1 4 2 3 2 3 6 6 6 6
YES
1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6
YES
1 1 1 1 3 3 3 3 5 5 5 5 2 2 2 2 4 4 4 4 6 6 6 6
NO
5 4 5 4 4 6 4 6 6 3 6 3 1 1 1 1 2 2 2 2 5 3 5 3
YES
3 3 5 5 2 2 2 2 6 6 4 4 6 3 6 3 4 5 4 5 1 1 1 1
YES
6 6 6 6 2 2 5 5 1 1 1 1 4 4 2 2 5 5 3 3 3 3 4 4
YES
4 6 4 6 6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 2 3 1 1 5 2 2 5 6 6 4 3 2 6 5 1 6
NO
5 2 5 2 3 5 3 5 4 3 4 3 6 6 6 6 1 1 1 1 4 2 4 2
YES
2 4 2 4 4 5 4 5 5 1 5 1 3 3 3 3 6 6 6 6 2 1 2 1
YES
3 5 3 5 5 1 5 1 1 4 1 4 6 6 6 6 2 2 2 2 3 4 3 4
YES
2 1 2 1 4 2 4 2 6 4 6 4 5 5 5 5 3 3 3 3 6 1 6 1
YES
4 4 2 2 1 1 1 1 5 5 6 6 2 6 2 6 4 5 4 5 3 3 3 3
YES
1 1 2 2 4 4 4 4 5 5 6 6 5 1 5 1 6 2 6 2 3 3 3 3
YES
2 2 6 6 4 4 4 4 1 1 5 5 1 2 1 2 5 6 5 6 3 3 3 3
YES
2 2 3 3 6 6 6 6 4 4 1 1 3 1 3 1 2 4 2 4 5 5 5 5
YES
6 6 6 6 4 4 3 3 5 5 5 5 3 3 1 1 2 2 4 4 1 1 2 2
YES
2 2 2 2 4 4 5 5 3 3 3 3 6 6 4 4 5 5 1 1 1 1 6 6
YES
1 1 1 1 5 5 6 6 3 3 3 3 4 4 5 5 6 6 2 2 2 2 4 4
YES
4 4 4 4 2 2 3 3 1 1 1 1 3 3 6 6 5 5 2 2 6 6 5 5
YES
1 1 1 1 2 2 3 3 6 6 6 6 5 5 4 4 3 3 2 2 4 4 5 5
NO
1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6
NO
5 5 5 5 1 1 2 2 6 6 6 6 4 4 3 3 3 3 4 4 2 2 1 1
NO
class Face:
	def __init__(self, a, b, c, d):
		self.a = a
		self.b = c
		self.c = b
		self.d = d

	def getStr(self, x = 0):
		return ('[{}, {},\n' + ' ' * x + '{}, {}]').format(self.a, self.b, self.c, self.d)

	def check(self):
		if self.a == self.b == self.c == self.d: return True
		return False

class Cube:
	def __init__(self, front, left, right, up, down, back):
		self.front = front
		self.left = left
		self.right = right
		self.up = up
		self.down = down
		self.back = back

	def __str__(self):
		return 'front: {}\nleft: {}\nright: {}\nup: {}\ndown: {}\nback: {}'.format(self.front.getStr(7), self.left.getStr(6), self.right.getStr(7), self.up.getStr(4), self.down.getStr(6), self.back.getStr(6))

	def next(self, curr, d):
		if d == 'up':
			if curr == 'front': return 'up'
			if curr == 'up': return 'back'
			if curr == 'back': return 'down'
			if curr == 'down': return 'front'
		if d == 'left':
			if curr == 'front': return 'left'
			if curr == 'left': return 'back'
			if curr == 'back': return 'right'
			if curr == 'right': return 'front'
		if d == 'right':
			if curr == 'front': return 'right'
			if curr == 'right': return 'back'
			if curr == 'back': return 'left'
			if curr == 'left': return 'front'
		if d == 'down':
			if curr == 'front': return 'down'
			if curr == 'down': return 'back'
			if curr == 'back': return 'up'
			if curr == 'up': return 'front'

		return d

	def changePerspective(self, d):
		self.front, self.left, self.right, self.up, self.down, self.back = getattr(self, self.next('front', d)), getattr(self, self.next('left', d)), getattr(self, self.next('right', d)), getattr(self, self.next('up', d)), getattr(self, self.next('down', d)), getattr(self, self.next('back', d))

	def rotate(self, block, d):
		next1 = self.next('front', d)
		next2 = self.next(next1, d)
		next3 = self.next(next2, d)
		next4 = self.next(next3, d) #same as front

		if block == 0:
			f, l = getattr(self, 'front'), getattr(self, next1)
			a, b = f.a, f.b
			l.a, l.b, a, b = a, b, l.a, l.b
			f, l = l, getattr(self, next2)
			l.a, l.b, a, b = a, b, l.a, l.b
			f, l = l, getattr(self, next3)
			l.a, l.b, a, b = a, b, l.a, l.b
			f, l = l, getattr(self, next4)
			l.a, l.b = a, b
		else:
			f, l = getattr(self, 'front'), getattr(self, next1)
			a, b = f.c, f.d
			l.c, l.d, a, b = a, b, l.c, l.d
			f, l = l, getattr(self, next2)
			l.c, l.d, a, b = a, b, l.c, l.d
			f, l = l, getattr(self, next3)
			l.c, l.d, a, b = a, b, l.c, l.d
			f, l = l, getattr(self, next4)
			l.c, l.d = a, b

	def check(self):
		return self.front.check() and self.left.check() and self.right.check() and self.up.check() and self.down.check() and self.back.check()

def checkSides(cube):
	cube.rotate(0, 'up');
	if cube.check(): return True
	cube.rotate(0, 'down'); cube.rotate(0, 'down')
	if cube.check(): return True
	cube.rotate(0, 'up')

	cube.rotate(1, 'up');
	if cube.check(): return True
	cube.rotate(1, 'down'); cube.rotate(1, 'down')
	if cube.check(): return True
	cube.rotate(1, 'up')

	cube.rotate(0, 'left');
	if cube.check(): return True
	cube.rotate(0, 'right'); cube.rotate(0, 'right')
	if cube.check(): return True
	cube.rotate(0, 'left')

	cube.rotate(1, 'left');
	if cube.check(): return True
	cube.rotate(1, 'right'); cube.rotate(1, 'right')
	if cube.check(): return True
	cube.rotate(1, 'left')

def go():
	faces = list(map(int, input().split(' ')))
	up = Face(faces[0], faces[1], faces[2], faces[3])
	front = Face(faces[4], faces[5], faces[6], faces[7])
	down = Face(faces[8], faces[9], faces[10], faces[11])
	left = Face(faces[12], faces[13], faces[14], faces[15])
	right = Face(faces[16], faces[17], faces[18], faces[19])
	back = Face(faces[21], faces[20], faces[23], faces[22])


	cube = Cube(front, left, right, up, down, back)
	if cube.check(): return True
	if checkSides(cube): return True

	cube.changePerspective('left')
	if checkSides(cube): return True

	cube.changePerspective('right')
	cube.changePerspective('up')
	if checkSides(cube): return True

	return False

if go(): print('YES')
else: print('NO')