Problem:
Dice III Write a program which reads the two dices constructed in the same way as Dice I , and determines whether these two dices are identical. You can roll a dice in the same way as Dice I , and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print " Yes " if two dices are identical, otherwise " No " in a line. Constraints  $0 \leq $ the integer assigned to a face $ \leq 100$  Sample Input 1 1 2 3 4 5 6
6 2 4 3 5 1 Sample Output 1 Yes Sample Input 2 1 2 3 4 5 6
6 5 4 3 2 1 Sample Output 2 No

Solution (Python):
dai=list(map(int,input().split()))
daini=list(map(int,input().split()))
def kouten():
	x=dai[0]
	dai[0]=dai[1]
	dai[1]=dai[5]
	dai[5]=dai[4]
	dai[4]=x
def sokuten():
	x=dai[0]
	dai[0]=dai[2]
	dai[2]=dai[5]
	dai[5]=dai[3]
	dai[3]=x

def tokei():
	dai1 = dai[1]
	dai[1] = dai[2]
	dai[2] = dai[4]
	dai[4] = dai[3]
	dai[3] = dai1
def check():
	for j in range(4):
		if daini[0] == dai[0] and daini[1] == dai[1] and daini[2] == dai[2] and daini[3] == dai[3] and daini[4] == dai[4] and daini[5] == dai[5]:
			print('Yes')
			return True
		tokei()
	return False
for a in range(3):
	if not check():
		kouten()
	else:
	 break
	if not check():
		sokuten()
	else:
		break
	if a==2:
		print('No')

Solution (Python):
D = [
    (1, 5, 2, 3, 0, 4), 
    (3, 1, 0, 5, 4, 2), 
    (4, 0, 2, 3, 5, 1), 
    (2, 1, 5, 0, 4, 3), 
]

*L1, = map(int, input().split())
*L2, = map(int, input().split())

p = (0, 0, 0, 1, 1, 2, 2, 3)*3
ok = 0
for k in p:
    if L1 == L2:
        ok = 1
    L2[:] = [L2[e] for e in D[k]]

print("Yes" if ok else "No")

Solution (Python):
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 

class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def equals(self,another):
 
        ret = False;
 
        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True
 
        return ret
 
diceA = Dice()
diceB = Dice()
 
table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
if diceA.equals(diceB):
    print("Yes")
else:
    print("No")

Solution (Python):
class Dice:
    
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

    def spin_horizontally(self):
        tmp = self.faces[1]
        self.faces[1] = self.faces[2]
        self.faces[2] = self.faces[4]
        self.faces[4] = self.faces[3]
        self.faces[3] = tmp

    def top(self):
        return self.faces[0]

    def front(self):
        return self.faces[1]

    def right(self):
        return self.faces[2]

n_a = list(map(int, input().split()))
n_b = list(map(int, input().split()))
dice_a = Dice(n_a[0], n_a[1], n_a[2], n_a[3], n_a[4], n_a[5])
dice_b = Dice(n_b[0], n_b[1], n_b[2], n_b[3], n_b[4], n_b[5])

ans = 'No'
for i in range(6):

    if i % 2 == 0:
        dice_a.move('S')
    else:
        dice_a.move('E')

    if dice_a.top() == dice_b.top():
        for _ in range(4):
            dice_a.spin_horizontally()
            if dice_a.front() == dice_b.front():
                break

    if dice_a.faces == dice_b.faces:
        ans = 'Yes'
        break
print(ans)

Solution (Python):
class Dice:
    def __init__(self,s):
        self.start = [0,1,2,4,3,5]
        self.s = s
        
    
    def N(self):
        self.start[0],self.start[1],self.start[3],self.start[5] = \
        self.start[1],self.start[5],self.start[0],self.start[3]
        
    def S(self):
        self.start[0],self.start[1],self.start[3],self.start[5] = \
        self.start[3],self.start[0],self.start[5],self.start[1]
        
    def W(self):
        self.start[0],self.start[2],self.start[4],self.start[5] = \
        self.start[2],self.start[5],self.start[0],self.start[4]
    
    def E(self):
        self.start[0],self.start[2],self.start[4],self.start[5] = \
        self.start[4],self.start[0],self.start[5],self.start[2]    


    
    def roll(self):
        self.start[1],self.start[2],self.start[3],self.start[4] = \
        self.start[4],self.start[1],self.start[2],self.start[3]          
    
    def get_top(self):
        return self.s[self.start[0]]
    
    def get_zhengMian(self):
        return self.s[self.start[1]]
    
    def get_right(self):
        return self.s[self.start[2]]
    
    def get_left(self):
        return self.s[self.start[4]]  
    
def is_same(dice1,dice2):
    FLAG = False
    dice1 = Dice(dice1)
    dice2 = Dice(dice2)
    a,b,c = dice1.get_top(),dice1.get_zhengMian(),dice1.get_right()
    d,e,f = dice2.get_top(),dice2.get_zhengMian(),dice2.get_right()
    
    
    
    if d==a:
        FLAG = True
    elif d!=a:
        tmp1,tmp2 = dice2.get_left(),dice2.get_right()
        if tmp1==a:
            dice2.E()
            FLAG = True
        elif tmp2==a:
            dice2.W()
            FLAG = True
        else:
            count = 0
            while True:
                count += 1
                tmp1 = dice2.get_top()
                if tmp1==a:
                    FLAG = True
                    break
                if count == 4:
                    break
                dice2.S()
    
    
    if FLAG==False:
        return FLAG
    b,e = dice1.get_zhengMian(),dice2.get_zhengMian()
    if e==b:
        FLAG = True
    elif e!=b:
        count = 0
        while True:
            count += 1
            tmp = dice2.get_zhengMian()
            if tmp==b:
                FLAG = True
                break
            if count==4:
                FLAG = False
                break
            dice2.roll()
    
    if FLAG==False:
        return FLAG
    else:
        f = dice2.get_right()
        if f==c:
            return True
        else:
            return False

if __name__=="__main__":
    dice1 = list(map(int,input().split()))
    dice2 = list(map(int,input().split()))
    tmp1 = dice1.copy();tmp2 = dice2.copy()
    tmp1.sort();tmp2.sort()
    num = 0;
    for i in range(1,6):
        if tmp1[i-1]!=tmp1[i]:
            num += 1
    if num<=2:
        print('Yes')
    else:
        bl = is_same(dice1, dice2)
        if bl == True:
            print('Yes')
        else:
            print('No')

Solution (Python):
a = list(map(int, input().split()))
d = list(map(int, input().split()))

rq = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for i in rq:
  if i == "E":
    d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
  elif i == "N":
    d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
  elif i == "S":
    d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
  elif i == "W":
    d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]

  if a == d:
      print("Yes")
      exit()

print("No")

Solution (Python):
import random
def dice(a,b,c,d,e,f,l):
    if l == "N":
        return [b,f,c,d,a,e]
    if l == "S":
        return [e,a,c,d,f,b]
    if l == "E":
        return [d,b,a,f,e,c]
    if l == "W":
        return [c,b,f,a,e,d]
d = list(map(int, input().split()))
s = ["W","N","E","S"]
a,b,c,g,e,f = map(int ,input().split())
j = 0
while j <= 10000:
    k = random.randrange(4)
    d = dice(d[0],d[1],d[2],d[3],d[4],d[5],s[k])
    if d[0] == a and d[1] == b and d[2] == c and d[3] == g and d[4] == e and d[5] == f:
        print("Yes")
        break
    if j == 10000:
        print("No")
    j += 1

Solution (Python):
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def equals(self,another):

        ret = False;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret

diceA = Dice()
diceB = Dice()

table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

if diceA.equals(diceB):
    print("Yes")
else:
    print("No")

Solution (Python):
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def equal(self, dice):  
        directions = "EEEENEEEENEEEENEEEEWSEEEESSEEEE"  
        for d in directions:
            self.roll(d)
            for i in range(6):
                if self.number[i] != dice.number[i]:
                    break
                if i == 5:
                    return True
        return False

num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
dice1 = Dice()
dice1.setNumber(num1[0], num1[1], num1[2], num1[3], num1[4], num1[5])
dice2 = Dice()
dice2.setNumber(num2[0], num2[1], num2[2], num2[3], num2[4], num2[5])
if dice1.equal(dice2):
    print("Yes")
else:
    print("No")

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
   
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
   
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
   
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
    
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 

class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def equals(self,another):
 
        ret = False;
 
        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True
 
        return ret
 
diceA = Dice()
diceB = Dice()
 
table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
if diceA.equals(diceB):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys


class Dice(object):
    def __init__(self, faces: list):
        self.list_sn = [faces[5], faces[4], faces[0], faces[1]]  
        self.list_we = [faces[5], faces[2], faces[0], faces[3]]  

    def _roll_positive(self, list_a: list, list_b: list) -> list:
        list_a = list_a[1:] + list_a[0:1]  
        list_b[0] = list_a[0]  
        list_b[2] = list_a[2]  
        return [list_a, list_b]

    def _roll_negative(self, list_a: list, list_b: list) -> list:
        list_a = list_a[3:] + list_a[0:3]
        list_b[0] = list_a[0]  
        list_b[2] = list_a[2]  
        return [list_a, list_b]

    def roll(self, direction: str):
        if "N" == direction:
            self.list_sn, self.list_we = self._roll_positive(self.list_sn, self.list_we)
        elif "S" == direction:
            self.list_sn, self.list_we = self._roll_negative(self.list_sn, self.list_we)
        elif "E" == direction:
            self.list_we, self.list_sn = self._roll_positive(self.list_we, self.list_sn)
        else:
            self.list_we, self.list_sn = self._roll_negative(self.list_we, self.list_sn)


if __name__ == "__main__":
    faces_dice_a = list(map(lambda x: int(x), input().split()))
    faces_dice_b = list(map(lambda x: int(x), input().split()))
    Dice_a = Dice(faces_dice_a)
    Dice_b = Dice(faces_dice_b)

    for command in "NNNNWNNNWNNNENNNENNNWNNN":  
        Dice_b.roll(command)
        if Dice_a.list_sn == Dice_b.list_sn and Dice_a.list_we == Dice_b.list_we:
            print("Yes")
            sys.exit()    
    print("No")

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
   
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
   
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
   
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
    
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def equals(self,another):

        ret = False;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret

diceA = Dice()
diceB = Dice()

table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

if diceA.equals(diceB):
    print("Yes")
else:
    print("No")

Solution (Python):

class dice():
    
    def __init__(self,a,b,c,d,e,f):
        self.A=[a,b,c,d,e,f]

class determine():

    def __init__(self,P,Q):
        self.P=P
        self.Q=Q
    def run(self):
  
        if (self.P.A[0]==self.Q.A[0] and self.P.A[5]==self.Q.A[5]):

            if self.P.A[1]==self.Q.A[1] and self.P.A[2]==self.Q.A[2] and self.P.A[3]==self.Q.A[3] and self.P.A[4]==self.Q.A[4]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[2] and self.P.A[2]==self.Q.A[4] and self.P.A[3]==self.Q.A[1] and self.P.A[4]==self.Q.A[3]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[4] and self.P.A[2]==self.Q.A[3] and self.P.A[3]==self.Q.A[2] and self.P.A[4]==self.Q.A[1]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[3] and self.P.A[2]==self.Q.A[1] and self.P.A[3]==self.Q.A[4] and self.P.A[4]==self.Q.A[2]:
                print("Yes")
            else:
                print("No")
        elif (self.P.A[0]==self.Q.A[1] and self.P.A[5]==self.Q.A[4]):
            if self.P.A[1]==self.Q.A[5] and self.P.A[2]==self.Q.A[2] and self.P.A[3]==self.Q.A[3] and self.P.A[4]==self.Q.A[0]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[2] and self.P.A[2]==self.Q.A[0] and self.P.A[3]==self.Q.A[5] and self.P.A[4]==self.Q.A[3]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[0] and self.P.A[2]==self.Q.A[3] and self.P.A[3]==self.Q.A[2] and self.P.A[4]==self.Q.A[5]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[3] and self.P.A[2]==self.Q.A[5] and self.P.A[3]==self.Q.A[0] and self.P.A[4]==self.Q.A[2]:
                print("Yes")
            else:
                print("No")

        elif (self.P.A[0]==self.Q.A[2]and self.P.A[5]==self.Q.A[3]):
            if self.P.A[1]==self.Q.A[1] and self.P.A[2]==self.Q.A[5] and self.P.A[3]==self.Q.A[0] and self.P.A[4]==self.Q.A[4]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[5] and self.P.A[2]==self.Q.A[4] and self.P.A[3]==self.Q.A[1] and self.P.A[4]==self.Q.A[0]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[4] and self.P.A[2]==self.Q.A[0] and self.P.A[3]==self.Q.A[5] and self.P.A[4]==self.Q.A[1]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[0] and self.P.A[2]==self.Q.A[1] and self.P.A[3]==self.Q.A[4] and self.P.A[4]==self.Q.A[5]:
                print("Yes")
            else:
                print("No")

        elif (self.P.A[0]==self.Q.A[3] and self.P.A[5]==self.Q.A[2]):
            if self.P.A[1]==self.Q.A[1] and self.P.A[2]==self.Q.A[0] and self.P.A[3]==self.Q.A[5] and self.P.A[4]==self.Q.A[4]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[0] and self.P.A[2]==self.Q.A[4] and self.P.A[3]==self.Q.A[1] and self.P.A[4]==self.Q.A[5]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[4] and self.P.A[2]==self.Q.A[5] and self.P.A[3]==self.Q.A[0] and self.P.A[4]==self.Q.A[1]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[5] and self.P.A[2]==self.Q.A[1] and self.P.A[3]==self.Q.A[4] and self.P.A[4]==self.Q.A[0]:
                print("Yes")
            else:
                print("No")

        elif (self.P.A[0]==self.Q.A[4] and self.P.A[5]==self.Q.A[1]):
            if self.P.A[1]==self.Q.A[0] and self.P.A[2]==self.Q.A[2] and self.P.A[3]==self.Q.A[3] and self.P.A[4]==self.Q.A[5]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[2] and self.P.A[2]==self.Q.A[5] and self.P.A[3]==self.Q.A[0] and self.P.A[4]==self.Q.A[3]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[5] and self.P.A[2]==self.Q.A[3] and self.P.A[3]==self.Q.A[2] and self.P.A[4]==self.Q.A[0]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[3] and self.P.A[2]==self.Q.A[0] and self.P.A[3]==self.Q.A[5] and self.P.A[4]==self.Q.A[2]:
                print("Yes")
            else:
                print("No")


        elif (self.P.A[0]==self.Q.A[5] and self.P.A[5]==self.Q.A[0]):
            if self.P.A[1]==self.Q.A[3] and self.P.A[2]==self.Q.A[4] and self.P.A[3]==self.Q.A[1] and self.P.A[4]==self.Q.A[2]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[4] and self.P.A[2]==self.Q.A[2] and self.P.A[3]==self.Q.A[3] and self.P.A[4]==self.Q.A[1]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[2] and self.P.A[2]==self.Q.A[1] and self.P.A[3]==self.Q.A[4] and self.P.A[4]==self.Q.A[3]:
                print("Yes")
            elif self.P.A[1]==self.Q.A[1] and self.P.A[2]==self.Q.A[3] and self.P.A[3]==self.Q.A[2] and self.P.A[4]==self.Q.A[4]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
     

if __name__=="__main__":
    
    def in_data():
       input_text=""
       input_text=input()
       array=[]
       array=input_text.split()
       return array
    
    
    
    number=in_data()
    
    ob1=dice( number[0], number[1], number[2], number[3], number[4], number[5])

    number=in_data()
    
    ob2=dice( number[0], number[1], number[2], number[3], number[4], number[5])

    
    det=determine(ob1,ob2)
        
    det.run()

Solution (Python):
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Solution (Python):
import random
def dice_move(a,s):
    if s=="E":
        return [a[3],a[1],a[0],a[5],a[4],a[2]]
    elif s=="S":
        return [a[4],a[0],a[2],a[3],a[5],a[1]]
    elif s=="W":
        return [a[2],a[1],a[5],a[0],a[4],a[3]]
    elif s=="N":
        return [a[1],a[5],a[2],a[3],a[0],a[4]]
    
a=list(map(int,input().split()))
b=list(map(int,input().split()))
h=("N","W","S","E")
for i in range(20000):
    num=random.randrange(4)
    a=dice_move(a,h[num])
    if a==b:
        print("Yes")
        exit()
print("No")