One day, Chef found a cube which has each of its sides painted in some color out of black, blue, red, green, yellow and orange.
Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same color.

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases.
- A single line of each test case contains six words denoting the colors of painted sides in the order: front, back, left, right, top and bottom, respectively.

-----Output-----
For each test case, output a single line containing the word "YES" or "NO" (without quotes) corresponding to the answer of the problem.

-----Constraints-----
- 1 ≤ T ≤  50000 
- Each color will be from the list {"black", "blue", "red", "green", "yellow", "orange"}

-----Subtasks-----
Subtask 1: (25 points)
- 1 ≤ T ≤  12000 
- For each test case there will be at most three different colors

Subtask 2: (75 points)
- Original constraints

-----Example-----
Input:
2
blue yellow green orange black green
green yellow green orange black green

Output:
NO
YES

-----Explanation-----

Example case 1.
There are no three sides with the same color.

Example case 2.
In this test case, the front, bottom and left sides are green (see picture).

Starter code:

Solutions:
for _ in range(int(input())):
 l=list(map(str,input().split()))
 a=[(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)]
 c=0
 for i in a:
  if len(set([l[i[0]-1],l[i[1]-1],l[i[2]-1]]))==1:
   c=1
   break
 if c==1:
  print("YES")
 else:
  print("NO")


# cook your dish here
for _ in range(int(input())):
 f, b, l, r, t, d = input().split()
 ans = False
 #front
 if (f == l or f == r) and (f == t or f == d): ans = True
 #back
 if (b == l or b == r) and (b == t or b == d): ans = True
 #top
 if (t == l or t == r) and (t == f or t == b): ans = True
 #down
 if (d == l or d == r) and (d == f or d == b): ans = True
 #left
 if (l == f or l == b) and (l == t or l == d): ans = True
 #right
 if (r == f or r == b) and (r == t or r == d): ans = True
 print("YES" if ans else "NO")
 


t=int(input())
for j in range(t):
 f,ba,l,r,t,bo=str(input()).split(" ")
 if(l==f and f==bo):
  print("YES")
 elif(l==f and l==t):
  print("YES")
 elif(l==t and t==ba):
  print("YES")
 elif(l==ba and ba==bo):
  print("YES")
 elif(f==t and t==r):
  print("YES")
 elif(t==ba and ba==r):
  print("YES")
 elif(bo==r and r==f):
  print("YES")
 elif(r==ba and ba==bo):
  print("YES")
 else:
  print("NO")

indices = [[0,2,4],[0,3,4],[0,2,5],[0,3,5],[1,2,4],[1,3,4],[1,2,5],[1,3,5]]
for _ in range(int(input())):
 color = list(map(str,input().split()))
 ans = "NO"
 for i in range(8):
  if color[indices[i][0]] == color[indices[i][1]] == color[indices[i][2]]:
   ans ="YES"
   break
 print(ans)


# cook your dish here
t=int(input())
for z in range(t):
 d=list(input().split())
 front, back, left, right, top, bottom=d[0],d[1],d[2],d[3],d[4],d[5] 
 if (front==left or front==right) and (front==top or front==bottom):
  print('YES')
 elif (back==left or back==right) and (back==top or back==bottom):
  print('YES')
 else:
  print('NO')

t=int(input())
for _ in range(t):
 s=input().split()
 d={}
 for i in range(6):
  try:
   d[s[i]].append(i)
  except:
   d[s[i]]=[i]
 flag=False
 for i in list(d.keys()):
  if len(d[i])>=3:
   if 0 in d[i] or 1 in d[i]:
    if (3 in d[i] or 2 in d[i]) and (4 in d[i] or 5 in d[i]):
     flag=True
     break
   

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


# cook your dish here
t = int(input())
for _ in range(t):
 s = input().split(' ')
 flag = 0
 if(s[0]==s[2]):
  if(s[0]==s[4] or s[0]==s[5]):
   flag = 1
 if(s[0]==s[3]):
  if(s[0]==s[4] or s[0]==s[5]):
   flag = 1
 if(s[1]==s[2]):
  if(s[1]==s[4] or s[1]==s[5]):
   flag = 1
 if(s[1]==s[3]):
  if(s[1]==s[4] or s[1]==s[5]):
   flag = 1
 if(flag==0):
  print('NO')
 else:
  print('YES')

for _ in range(int(input())):
 a = input().split()
 y = 0
 if(a[4]==a[0]==a[3]):
  y=1
 elif(a[4]==a[0]==a[2]):
  y=1
 elif(a[4]==a[1]==a[3]):
  y=1
 elif(a[4]==a[1]==a[2]):
  y=1
 elif(a[5]==a[0]==a[3]):
  y=1
 elif(a[5]==a[0]==a[2]):
  y=1
 elif(a[5]==a[1]==a[3]):
  y=1
 elif(a[5]==a[1]==a[2]):
  y=1
 if(y==1):
  print("YES") 
 else:
  print("NO") 
 


for t in range(int(input())):
 s = input().split()
 d, loc, p = {}, [], 0
 for x in range(6):
  if s[x] in d: d[s[x]].append(x)
  else: d[s[x]] = [x]
 for i in d:
  if len(d[i]) >= 3:
   loc = d[i]
   break
 for l in range(0, 5, 2):
  if l in loc or (l + 1) in loc: p += 1
 if p == 3: print('YES')
 else: print('NO')

pairwise=[[0,2,4],[0,3,4],[1,3,4],[1,2,4],
   [0,2,5],[0,3,5],[1,3,5],[1,2,5]]
for _ in range(int(input())):
 c=input().split()
 ans="NO"
 for i in pairwise:
  x,y,z=i
  if c[x]==c[y]==c[z]:
   ans="YES"
   break
 print(ans)

import math
import sys

def _int():
 return int(sys.stdin.readline())

def _ints():
 return list(map(int, sys.stdin.readline().split()))

def _intarr():
 return list(map(int, sys.stdin.readline().split()))

def _str():
 return sys.stdin.readline()

def _strarr():
 return sys.stdin.readline().split()

def adj(a, b, c):
 if b != opp[a] and b != opp[c] and a != opp[c]:
  return True
 return False

t = _int()

opp = [1, 0, 3, 2, 5, 4]

for _ in range(t):
 c = _strarr()
 cd = dict()
 for i in range(len(opp)):
  ind = cd.get(c[i], [])
  ind.append(i)
  cd[c[i]] = ind
 
 #print(cd)

 found = False
 for k in list(cd.keys()):
  ind = cd.get(k, [])
  if len(ind) == 3:
   if adj(ind[0], ind[1], ind[2]):
     found = True
  elif len(ind) == 4:
   if adj(ind[0], ind[1], ind[2]):
    found = True
   elif adj(ind[0], ind[1], ind[3]):
    found = True
   elif adj(ind[0], ind[2], ind[3]):
    found = True
   elif adj(ind[1], ind[2], ind[3]):
    found = True
  elif len(ind) >= 5:
   found = True
  if found:
   break
 print("YES" if found else "NO")