import sys
input = sys.stdin.readline
def f(a1, b1, c1, d1, e1, f1, g):
a, b, c, d, e, f = a1.copy(), b1.copy(), c1.copy(), d1.copy(), e1.copy(), f1.copy()
if len(set(a)) == len(set(b)) == 1:
if g == 1:
for i in [c, d, e, f]:
i[1], i[2] = i[2], i[1]
elif g == 2:
d[1], d[2] = d[2], d[1]
e[0], e[1], e[2], e[3] = e[2], e[3], e[0], e[1]
f[0], f[3] = f[3], f[0]
if f[0] == f[1]:
x = f[0]
for i1, i2, i3, i4 in [c,d,e,f]:
if x == i3 == i4:
if i1 == i2:
x = i1
else:
break
else:
break
else:
return 1
x = f[0]
for i1, i2, i3, i4 in [e,d,c,f]:
if x == i3 == i4:
if i1 == i2:
x = i1
else:
break
else:
break
else:
return 1
return 0
w = list(map(int, input().split()))
a1 = w[:4]
a2 = w[4:8]
a3 = w[8:12]
a4 = w[12:16]
a5 = w[16:20]
a6 = [w[21], w[20], w[23], w[22]]
if sum([f(a1, a3, a4, a2, a5, a6, 0), f(a2, a6, a1, a4, a3, a5, 2), f(a4, a5, a1, a2, a3, a6, 1)]) >= 1:
print('YES')
else:
print('NO')
1302. Deepest Leaves Sum | 1209. Remove All Adjacent Duplicates in String II |
994. Rotting Oranges | 983. Minimum Cost For Tickets |
973. K Closest Points to Origin | 969. Pancake Sorting |
967. Numbers With Same Consecutive Differences | 957. Prison Cells After N Days |
946. Validate Stack Sequences | 921. Minimum Add to Make Parentheses Valid |
881. Boats to Save People | 497. Random Point in Non-overlapping Rectangles |
528. Random Pick with Weight | 470. Implement Rand10() Using Rand7() |
866. Prime Palindrome | 1516A - Tit for Tat |
622. Design Circular Queue | 814. Binary Tree Pruning |
791. Custom Sort String | 787. Cheapest Flights Within K Stops |
779. K-th Symbol in Grammar | 701. Insert into a Binary Search Tree |
429. N-ary Tree Level Order Traversal | 739. Daily Temperatures |
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |