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
from sys import stdin
s=list(map(int,stdin.readline().strip().split()))
l1=[s[0],s[2],s[4],s[6],s[8],s[10],s[-3],s[-1]]
l2=[s[1],s[3],s[5],s[7],s[9],s[11],s[-4],s[-2]]
l3=[ s[12],s[13],s[4],s[5],s[16],s[17],s[20],s[21]]
l4=[s[14],s[15],s[6],s[7],s[18],s[19],s[22],s[23]]
t1=True
t12=True
t2=False
t32=True
t3=True
t4=False
for i in range(2,8+2):
    if l1[i%8]!=l2[i-2]:
        t1=False
for i in range(6,8+6):
    if l1[i%8]!=l2[i-6]:
        t12=False
if l3[0]==l4[0] and l3[1]==l4[1] and l3[0]==l3[1] and  l3[4]==l4[4] and  l3[5]==l4[5] and l3[4]==l3[5]:
    t2=True
for i in range(2,8+2):
    if l1[i%8]!=l2[i-2]:
        t3=False
for i in range(6,8+6):
    if l1[i%8]!=l2[i-6]:
        t32=False
t3=t3 or t32
t1=t1 or t12
if l1[0]==l2[0] and l1[1]==l2[1] and l1[0]==l2[1] and  l1[4]==l1[4] and  l1[5]==l2[5] and l1[4]==l1[5]:
    t2=True
if ( t1 and t2 ) or (t3 and t4):
    print("YES")
else:
    print("NO")
