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 copy import deepcopy

def sync(cube, where):
    matching = [[2,6],[7,3]]
    if where == 1: ## 가로로 움직였다면
        l, f = matching
        for i in range(2):
            for j in range(2):
                lx, ly = l[0]+i, l[1] + j
                fx, fy = f[0] - i, f[1] - j
                cube[fx][fy] = cube[lx][ly]
                
    elif where == 2: ## 세로로 움직였다면
        f, l = matching
        for i in range(2):
            for j in range(2):
                lx, ly = l[0] - i, l[1] - j
                fx, fy = f[0] + i, f[1] + j
                cube[fx][fy] = cube[lx][ly]
                
    
    return cube

def check(cube):
    global start_loc
    flag = True
    for part, loc in start_loc.items():
        color = -1
        sx,sy = loc
        for i in range(2):
            for j in range(2):
                x,y = sx+i, sy+j
                if color == -1:
                    color = cube[x][y]
                if color != cube[x][y]: return False
    
    return flag

#############################################################################################################################
## rotate만 구현하면 된다.
def vertical(cube, line, dir): ## 세로
    """
    line => col 2, col 3
    dir => 1 : 위,  2 : 아래
    """
    if dir == 1:  ## 위
        temp1 = cube[0][line]
        temp2 = cube[1][line]
        for i in range(2, 8):
            cube[i-2][line] = cube[i][line]
        cube[6][line] = temp1
        cube[7][line] = temp2
    elif dir == 2: ## 아래
        temp1 = cube[7][line]
        temp2 = cube[6][line]
        for i in range(7, 1, -1):
            cube[i][line] = cube[i-2][line]
        cube[1][line] = temp1
        cube[0][line] = temp2
        
    cube = sync(cube, 2)
    return check(cube)
    

def horizontal(cube, line, dir): ## 가로
    """
    line => row 2, row 3
    dir => 1 : 오른쪽,  2 : 왼쪽
    """
    if dir == 1:
        cube[line] = cube[line][-2:] + cube[line][:-2]
    elif dir == 2:
        cube[line] = cube[line][2:] + cube[line][:2]
        
    cube = sync(cube, 1)
    return check(cube)
    

cube = [[0]*8 for _ in range(8)]
start_loc = {0 : (0,2), 1 : (2,2), 2: (4,2), 3: (2,0), 4:(2,4), 5:(2,6)}
colors = []
init = list(map(int, input().split()))
start = 0
for i in range(24):
    if i %4 == 3:
        num1,num2, num3, num4 = init[start:start+4]
        color  = [[num1,num2],[num3, num4]]
        colors.append(color)
        start += 4
        
for order, loc in start_loc.items():
    sx, sy = loc
    color = colors[order]
    for i in range(2):
        for j in range(2):
            x,y = sx+i, sy+j
            cube[x][y] = color[i][j]

cube = sync(cube, 1)
"""
cube 회전할 line
Horizontal => row 2, row 3
Vertical => col 2, col 3 

Direction
1 => 오른쪽 or 위
2 => 왼쪽 or 아래

Horizontal => line x dir : 4가지 경우
Vertical => line x dir : 4가지 경우

따라서 총 8가지 경우 Check 필요하다
"""



flag = False
for mode in range(1, 3):
    for line in range(2,4):
        for dir in range(1,3):
            temp_cube = deepcopy(cube)
            if mode == 1: ## Horizontal
                flag = horizontal(temp_cube, line, dir)
            elif mode == 2: ## Vertical
                flag = vertical(temp_cube, line, dir)
            del temp_cube
            
            if flag: break
        if flag: break
    if flag: break

print(flag)