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):
class Dice:
    def __init__(self, d1, d2, d3, d4, d5, d6):
        self.d1 = d1
        self.d2 = d2
        self.d3 = d3
        self.d4 = d4
        self.d5 = d5
        self.d6 = d6
    def S(self):
        tmp = self.d1
        self.d1 = self.d5
        self.d5 = self.d6
        self.d6 = self.d2
        self.d2 = tmp
    def N(self):
        tmp = self.d1
        self.d1 = self.d2
        self.d2 = self.d6
        self.d6 = self.d5
        self.d5 = tmp
    def E(self):
        tmp = self.d1
        self.d1 = self.d4
        self.d4 = self.d6
        self.d6 = self.d3
        self.d3 = tmp
    def W(self):
        tmp = self.d1
        self.d1 = self.d3
        self.d3 = self.d6
        self.d6 = self.d4
        self.d4 = tmp
    def comp(self, a, b, c):
        if (a == self.d1 and b == self.d2) or (a == self.d2 and b == self.d6) \
         or (a == self.d6 and b == self.d5) or (a == self.d5 and b == self.d1):
            if c == self.d3:
                return True
        if (a == self.d2 and b == self.d1) or (a == self.d6 and b == self.d2) \
         or (a == self.d5 and b == self.d6) or (a == self.d1 and b == self.d5):
            if c == self.d4:
                return True
        if (a == self.d1 and b == self.d3) or (a == self.d3 and b == self.d6) \
         or (a == self.d6 and b == self.d4) or (a == self.d4 and b == self.d1):
            if c == self.d5:
                return True
        if (a == self.d3 and b == self.d1) or (a == self.d6 and b == self.d3) \
         or (a == self.d4 and b == self.d6) or (a == self.d1 and b == self.d4):
            if c == self.d2:
                return True
        if (a == self.d2 and b == self.d3) or (a == self.d3 and b == self.d5) \
         or (a == self.d5 and b == self.d4) or (a == self.d4 and b == self.d2):
            if c == self.d1:
                return True
        if (a == self.d3 and b == self.d2) or (a == self.d5 and b == self.d3) \
         or (a == self.d4 and b == self.d5) or (a == self.d2 and b == self.d4):
            if c == self.d6:
                return True
        return False

d1, d2, d3, d4, d5, d6 = map(int, input().split())
dice = Dice(d1, d2, d3, d4, d5, d6)
d1, d2, d3, d4, d5, d6 = map(int, input().split())
OK = dice.comp(d1, d2, d3)
if OK:
    OK = dice.comp(d2, d6, d3)
if OK:
    OK = dice.comp(d6, d5, d3)
if OK:
    OK = dice.comp(d5, d1, d3)
if OK:
    OK = dice.comp(d2, d1, d4)
if OK:
    OK = dice.comp(d6, d2, d4)
if OK:
    OK = dice.comp(d5, d6, d4)
if OK:
    OK = dice.comp(d1, d5, d4)
if OK:
    OK = dice.comp(d1, d3, d5)
if OK:
    OK = dice.comp(d3, d6, d5)
if OK:
    OK = dice.comp(d6, d4, d5)
if OK:
    OK = dice.comp(d4, d1, d5)
if OK:
    OK = dice.comp(d3, d1, d2)
if OK:
    OK = dice.comp(d1, d4, d2)
if OK:
    OK = dice.comp(d4, d6, d2)
if OK:
    OK = dice.comp(d6, d3, d2)
if OK:
    OK = dice.comp(d2, d3, d1)
if OK:
    OK = dice.comp(d3, d5, d1)
if OK:
    OK = dice.comp(d5, d4, d1)
if OK:
    OK = dice.comp(d4, d2, d1)
if OK:
    OK = dice.comp(d3, d2, d6)
if OK:
    OK = dice.comp(d2, d4, d6)
if OK:
    OK = dice.comp(d4, d5, d6)
if OK:
    OK = dice.comp(d5, d3, d6)
if OK:
    print('Yes')
else:
    print('No')

Solution (Python):
class Dice:
  def __init__(self, list1):
    self.f = list1

  def spin1(self):  
    f = self.f
    self.spin2()
    f[0], f[2], f[3], f[5] = f[3], f[0], f[5], f[2]
    f[0], f[1], f[4], f[5] = f[4], f[0], f[5], f[1]
    return f[:]

  def spin2(self):  
    f = self.f
    f[0], f[1], f[4], f[5] = f[1], f[5], f[0], f[4]
    return f[:]
    
  def spin3(self):  
    f = self.f
    f[0], f[2], f[3], f[5] = f[2], f[5], f[0], f[3]
    return f[:]


data = list(map(int, input().split()))
dice_1 = Dice(data)

data_2 = [dice_1.spin2() for _ in range(4)]
for j in data_2[:]:
    dice_2 = Dice(j)
    data_2 += [dice_2.spin1() for _ in range(4)]

data_4 = []
for l in data_2:
    dice_3 = Dice(l)
    data_4 += [dice_3.spin3() for _ in range(4)]

data_1 = list(map(int, input().split()))
if data_1 in data_4:
    print("Yes")
else:
    print("No")

Solution (Python):
class Dice:
  def __init__(self, list1):
    self.f = list1
  def spin1(self):
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[3], self.f[0], self.f[5], self.f[2]
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[4], self.f[0], self.f[5], self.f[1]
    return self.f
  def spin2(self):
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    return self.f
  def spin3(self):
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[2], self.f[5], self.f[0], self.f[3]
    return self.f

data = list(map(int, input().split()))
data_1 = list(map(int, input().split()))
data_2 = []
data_3 = []
data_4 = []
dice_1 = Dice(data)
for i in range(0, 4):
    a = dice_1.spin2()
    b = a[:]
    data_2.append(b)

for j in data_2:
    dice_2 = Dice(j)
    for k in range(0, 4):
        c = dice_2.spin1()
        d = c[:]
        data_3.append(d)
data_5 = data_2 + data_3

for l in data_5:
    dice_3 = Dice(l)
    for m in range(0, 4):
        e = dice_3.spin3()
        f = e[:]
        data_4.append(f)

if data_1 in data_4:
    print("Yes")
else:
    print("No")

Solution (Python):
import copy


class Dice:
    def __init__(self, eyes: [int]):
        self.__eyes = eyes

    @property
    def eyes(self):
        return self.__eyes

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

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

    def roll_s(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[4]
        tmp[1] = self.__eyes[0]
        tmp[2] = self.__eyes[2]
        tmp[3] = self.__eyes[3]
        tmp[4] = self.__eyes[5]
        tmp[5] = self.__eyes[1]
        self.__eyes = tmp

    def roll_e(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[3]
        tmp[1] = self.__eyes[1]
        tmp[2] = self.__eyes[0]
        tmp[3] = self.__eyes[5]
        tmp[4] = self.__eyes[4]
        tmp[5] = self.__eyes[2]
        self.__eyes = tmp

    def roll_n(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[1]
        tmp[1] = self.__eyes[5]
        tmp[2] = self.__eyes[2]
        tmp[3] = self.__eyes[3]
        tmp[4] = self.__eyes[0]
        tmp[5] = self.__eyes[4]
        self.__eyes = tmp

    def roll_w(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[2]
        tmp[1] = self.__eyes[1]
        tmp[2] = self.__eyes[5]
        tmp[3] = self.__eyes[0]
        tmp[4] = self.__eyes[4]
        tmp[5] = self.__eyes[3]
        self.__eyes = tmp

    def turn_right(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[0]
        tmp[1] = self.__eyes[3]
        tmp[2] = self.__eyes[1]
        tmp[3] = self.__eyes[4]
        tmp[4] = self.__eyes[2]
        tmp[5] = self.__eyes[5]
        self.__eyes = tmp

    def adjust_top(self, top: int):
        for _ in range(4):
            if self.top() is top:
                break
            self.roll_e()
        for _ in range(4):
            if self.top() is top:
                break
            self.roll_s()

    def adjust_front(self, front: int):
        for _ in range(4):
            if self.front() is front:
                break
            self.turn_right()

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

    def roll(self, direction: str):
        if direction.lower() == 'n':
            self.roll_n()
        if direction.lower() == 'e':
            self.roll_e()
        if direction.lower() == 's':
            self.roll_s()
        if direction.lower() == 'w':
            self.roll_w()


def resolve():
    eyes1 = list(map(int, input().split()))
    eyes2 = list(map(int, input().split()))

    dice1 = Dice(eyes1)
    dice2 = Dice(eyes2)

    random1 = max(set(eyes1+eyes2))

    dice1.adjust_top(random1)
    dice2.adjust_top(random1)

    dice2.adjust_front(dice1.front())

    if dice1.eyes == dice2.eyes:
        print('Yes')
    else:
        print('No')



resolve()

Solution (Python):
dice1 = [int(i) for i in input().split()]
dice2 = [int(i) for i in input().split()]

if dice2[0] == dice1[1]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[1], dice1[5], dice1[0], dice1[4]
elif dice2[0] == dice1[2]:
    dice1[0], dice1[2], dice1[3], dice1[5] = dice1[2], dice1[5], dice1[0], dice1[3]
elif dice2[0] == dice1[3]:
    dice1[0], dice1[2], dice1[3], dice1[5] = dice1[3], dice1[0], dice1[5], dice1[2]
elif dice2[0] == dice1[4]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[4], dice1[0], dice1[5], dice1[1]
elif dice2[0] == dice1[5]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[5], dice1[4], dice1[1], dice1[0]

while dice2[1] != dice1[1]:
    dice1[1], dice1[2], dice1[4], dice1[3] = dice1[3], dice1[1], dice1[2], dice1[4]
    
if dice1 == dice2:
    print('Yes')
else:
    print('No')

Solution (Python):
class Dice:
    def __init__(self, a, b, c, d, e, f):
        
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

        
        self.result = 0

    def move(self, move_str):
        for i in move_str:
            if i == "N":
                self.move_N()
            elif i == "E":
                self.move_E()
            elif i == "W":
                self.move_W()
            elif i == "S":
                self.move_S()

    def move_N(self):
        tmp1 = self.a
        tmp2 = self.e
        self.a = self.b
        self.b = self.f
        self.e = tmp1
        self.f = tmp2

    def move_E(self):
        tmp1 = self.a
        tmp2 = self.c
        self.a = self.d
        self.c = tmp1
        self.d = self.f
        self.f = tmp2

    def move_W(self):
        tmp1 = self.a
        tmp2 = self.d
        self.a = self.c
        self.c = self.f
        self.d = tmp1
        self.f = tmp2

    def move_S(self):
        tmp1 = self.a
        tmp2 = self.b
        self.a = self.e
        self.b = tmp1
        self.e = self.f
        self.f = tmp2

    def check_one_around(self, dice):
        """チェックのために時計回りに一周させる"""
        for _ in range(4):
            """時計回りに回転"""
            tmp1 = self.b
            tmp2 = self.d
            self.b = self.c
            self.c = self.e
            self.d = tmp1
            self.e = tmp2

            
            self.check_dice_same(dice)

    def check_dice_same(self, dice):
        """引数指定したダイスと同一面かチェック"""
        if (
            self.a == dice.a and
            self.b == dice.b and
            self.c == dice.c and
            self.d == dice.d and
            self.e == dice.e and
            self.f == dice.f
        ):
            self.result += 1

    def all_check(self, dice):
        dice1.check_one_around(dice)
        
        dice1.move("N")
        dice1.check_one_around(dice)

        
        dice1.move("W")
        dice1.check_one_around(dice)

        
        dice1.move("W")
        dice1.check_one_around(dice)

        
        dice1.move("W")
        dice1.check_one_around(dice)

        
        dice1.move("N")
        dice1.check_one_around(dice)

    def clear_result(self):
        self.result = 0


a, b, c, d, e, f = map(int, input().split())
dice1 = Dice(a, b, c, d, e, f)
a, b, c, d, e, f = map(int, input().split())
dice2 = Dice(a, b, c, d, e, f)
dice1.all_check(dice2)

if dice1.result != 0:
    print("Yes")
else:
    print("No")

Solution (Python):
class Dice():
    
    def __init__(self,numlist):
        self.lst=numlist
    
    def roll(self,direction):
        for x in direction:
            if x=="S" : self.lst=[self.lst[4],self.lst[0],self.lst[2],self.lst[3],self.lst[5],self.lst[1]]
            elif x=="N" : self.lst=[self.lst[1],self.lst[5],self.lst[2],self.lst[3],self.lst[0],self.lst[4]]
            elif x=="W" : self.lst=[self.lst[2],self.lst[1],self.lst[5],self.lst[0],self.lst[4],self.lst[3]]
            elif x=="E" : self.lst=[self.lst[3],self.lst[1],self.lst[0],self.lst[5],self.lst[4],self.lst[2]]        
    
    def dice_set_make(self):
        self.dice_set=[]
        for x in ["","W","WW","WWW","SE","SW"]:
            self.work=Dice(self.lst[:])
            self.work.roll(x)
            self.dice_set.append(self.work.lst)
            for _ in range(3):
                self.work.roll("S")
                self.dice_set.append(self.work.lst)
        

lst=list(map(int,input().split()))
d1=Dice(lst)
d1.dice_set_make()
dice_set=d1.dice_set
lst2=list(map(int,input().split()))

if lst2 in dice_set:
    print("Yes")
else : print("No")

Solution (Python):
class Dice:
    D = {'E': (3, 1, 0, 5, 4, 2),
         'W': (2, 1, 5, 0, 4, 3),
         'S': (4, 0, 2, 3, 5, 1),
         'N': (1, 5, 2, 3, 0, 4)}
    def __init__(self, a, b, c, d, e, f):
        self.nbrs = [a, b, c, d, e, f]
        self.tp = a
        self.fwd = b
        self.rs = c
        self.ls = d
        self.bk = e
        self.bm = f
    def rll(self, dr):
        self.nbrs = [self.nbrs[i] for i in self.D[dr]]
        self.tp = self.nbrs[0]
        self.fwd = self.nbrs[1]
        self.rs = self.nbrs[2]
        self.ls = self.nbrs[3]
        self.bk = self.nbrs[4]
        self.bm = self.nbrs[5]


a, b, c, d, e, f = input().split()
dice1 = Dice(a, b, c, d, e, f)
a, b, c, d, e, f = input().split()
dice2 = Dice(a, b, c, d, e, f)
for i in 'NNNN':
    dice2.rll(i)
    for i in 'EEEE':
        dice2.rll(i)
        for i in 'NNNN':
            dice2.rll(i)
            if dice2.nbrs == dice1.nbrs:
                print('Yes')
                exit()
print('No')

Solution (Python):
class Dice():
    def __init__(self, spots):
        self.spots = [spots[i] for i in range(6)]
    
    def roll(self, direction):
        if direction == 0:
            self.spots = [self.spots[i] for i in [1, 5, 2, 3, 0, 4]]
        elif direction == 1:
            self.spots = [self.spots[i] for i in [3, 1, 0, 5, 4, 2]]
        elif direction == 2:
            self.spots = [self.spots[i] for i in [4, 0, 2, 3, 5, 1]]
        elif direction == 3:
            self.spots = [self.spots[i] for i in [2, 1, 5, 0, 4, 3]]
            
dice_a = list(map(int, input().split()))
dice_b = list(map(int, input().split()))

my_dice = Dice(dice_a)

a, b = dice_b[0], dice_b[1]

if b == my_dice.spots[0]:
    my_dice.roll(2)
elif b == my_dice.spots[1]:
    pass
elif b == my_dice.spots[2]:
    my_dice.roll(3)
    my_dice.roll(2)
elif b == my_dice.spots[3]:
    my_dice.roll(1)
    my_dice.roll(2)
elif b == my_dice.spots[4]:
    my_dice.roll(2)
    my_dice.roll(2)
elif b == my_dice.spots[5]:
    my_dice.roll(0)

if a == my_dice.spots[0]:
    pass
elif a == my_dice.spots[2]:
    my_dice.roll(3)
elif a == my_dice.spots[3]:
    my_dice.roll(1)
elif a == my_dice.spots[5]:
    my_dice.roll(1)
    my_dice.roll(1)
    
if my_dice.spots == dice_b:
    print('Yes')
else:
    print('No')

Solution (Python):
dice = list(input().split(' '))
a = list('NNNNWNNNWNNNENNNENNNWNNN')
x = 0
aa,bb,cc,dd,ee,ff  = input().split(' ')
for i in a:
    if i == 'W':
        dice = [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]]
    elif i == 'S':
        dice = [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]]
    elif i == 'N':
        dice = [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]]
    elif i == 'E':
        dice = [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]]
    if dice[0] == aa and dice[1] == bb and dice[2] == cc and dice[3] == dd and dice[4] == ee and dice[5] == ff:
        x = x + 1
kome = 'Yes' if x > 0 else 'No'
print(kome)

Solution (Python):
class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def toN(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def toE(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def toS(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def toW(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

    def printTop(self):
        print(self.top)

    def printWest(self):
        print(self.west)

    def printEast(self):
        print(self.east)

    def getTop(self, target):
        if self.top == target:
            return
        for i in range(3):
            self.toN()
            if self.top == target:
                return
        for i in range(3):
            self.toE()
            if self.top == target:
                return

        if self.top != target:
            print("Error")

    def getSouth(self, target):
        if self.south == target:
            return
        for i in range(3):
            self.lotate()
            if self.south == target:
                return
    
    def lotate(self):
        tmp = self.north
        self.north = self.east
        self.east = self.south
        self.south = self.west
        self.west = tmp

    def isSame(self, other):
        if self.top == other.top and \
           self.north == other.north and \
           self.east == other.east and \
           self.south == other.south and \
           self.west == other.west and \
           self.bottom == other.bottom:
            return True
        else:
            return False

    def compare(self, other):
        for i in range(4):
            for j in range(4):
                if self.isSame(other) == True:
                    return True
                self.lotate()
            self.toN()

        for i in range(4):
            for j in range(4):
                if self.isSame(other) == True:
                    return True
                self.lotate()
            self.toE()
        return False

n = input().split()
dice1 = Dice(int(n[0]), int(n[1]), int(n[2]), int(n[3]), int(n[4]), int(n[5]))                                                 
n = input().split()
dice2 = Dice(int(n[0]), int(n[1]), int(n[2]), int(n[3]), int(n[4]), int(n[5]))

if dice1.compare(dice2) == True:
    print("Yes")
else:
    print("No")

Solution (Python):
class Dice:
    def __init__(self, ary): 
        self.__top = ary[0]
        self.__fro = ary[1]
        self.__rit = ary[2]
        self.__lft = ary[3]
        self.__bak = ary[4]
        self.__btm = ary[5]

    def turn_e(self): 
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__lft, self.__btm, self.__rit, self.__top

    def turn_s(self): 
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__bak, self.__top, self.__fro, self.__btm

    def turn_w(self): 
        self.__top, self.__lft, self.__btm, self.__rit = \
        self.__rit, self.__top, self.__lft, self.__btm

    def turn_n(self): 
        self.__top, self.__fro, self.__btm, self.__bak = \
        self.__fro, self.__btm, self.__bak, self.__top

    def spin_r(self): 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__bak, self.__rit, self.__fro, self.__lft

    def spin_l(self): 
        self.__rit, self.__fro, self.__lft, self.__bak = \
        self.__fro, self.__lft, self.__bak, self.__rit

    def is_same_setting(self, ary): 
        if self.__top == ary[0] and self.__fro == ary[1] and self.__rit == ary[2] and \
            self.__lft == ary[3] and self.__bak == ary[4] and self.__btm == ary[5]:
            return True

    def is_same_dice(self, ary): 
        is_same = False
        for _ in range(2):
            for _ in range(3):
                for _ in range(4):
                    if self.is_same_setting(ary):
                        is_same = True
                    self.spin_r()
                self.turn_n()
            self.spin_r()
            self.turn_s()
        return is_same

    def show_top(self): 
        return self.__top


surfaces1 = list(map(int,input().split()))
surfaces2 = list(map(int,input().split()))

dice = Dice(surfaces1)

if dice.is_same_dice(surfaces2):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
reverse = {
    "E":"W",
    "W":"E",
    "S":"N",
    "N":"S"
    }
        
class dice:
    def __init__(self,A):
        self.list = sorted(A)
        self.max = max(A)
        self.min = min(A)
        self.side = {
            "TOP":A[0],
            "S":A[1],
            "E":A[2],
            "W":A[3],
            "N":A[4],
            "BOT":A[5],
            }
    def get_list(self):
        return self.list
    def get_dict(self):
        return self.side
    def check(self):
        pass
    def main(self,A):
        for s in A:
            var = int(self.side[s])
            self.side[s] = self.side["TOP"]
            self.side["TOP"] = self.side[reverse[s]]
            self.side[reverse[s]] = self.side["BOT"]
            self.side["BOT"] = var
    def rot(self):
        var = self.side["N"]
        self.side["N"] = self.side["E"]
        self.side["E"] = self.side["S"]
        self.side["S"] = self.side["W"]
        self.side["W"] = var
    def rotate(self,top,flont):
        self.top_set(top)
        for x in range(4):
            if self.side["S"] == flont:
                break
            else:
                var = int(self.side["N"])
                self.side["N"] = self.side["E"]
                self.side["E"] = self.side["S"]
                self.side["S"] = self.side["W"]
                self.side["W"] = var
        return list([self.side["TOP"],self.side["S"],self.side["E"]])
    def top_set(self,top):
        if self.side["BOT"] == top:
            self.main("NN")
        elif self.side["N"] == top:
            self.main("S")
        elif self.side["S"] == top:
            self.main("N")
        elif self.side["E"] == top:
            self.main("W")
        elif self.side["W"] == top:
            self.main("E")


a = dice(list(map(int,input().split())))
b = dice(list(map(int,input().split())))

a_list = a.get_list()
b_list = b.get_list()

if a_list != b_list:
    print("No")
else:
    a_dict = a.get_dict()
    for do in ["N","N","N","N","E","EE"]:
        b.main(do)
        for i in range(4):
            b.rot()
            if a_dict == b.get_dict():
                print("Yes")
                sys.exit()
                break
        else:
            continue
        break

print("No")

Solution (Python):
patterns = [
    [1, 2, 3, 4, 5, 6],
    [1, 3, 5, 2, 4, 6],
    [1, 5, 4, 3, 2, 6],
    [1, 4, 2, 5, 3, 6],
    [2, 6, 3, 4, 1, 5],
    [2, 3, 1, 6, 4, 5],
    [2, 1, 4, 3, 6, 5],
    [2, 4, 6, 1, 3, 5],
    [3, 6, 5, 2, 1, 4],
    [3, 5, 1, 6, 2, 4],
    [3, 1, 2, 5, 6, 4],
    [3, 2, 6, 1, 5, 4],
    [4, 6, 2, 5, 1, 3],
    [4, 2, 1, 6, 5, 3],
    [4, 1, 5, 2, 6, 3],
    [4, 5, 6, 1, 2, 3],
    [5, 3, 6, 1, 4, 2],
    [5, 6, 4, 3, 1, 2],
    [5, 4, 1, 6, 3, 2],
    [5, 1, 3, 4, 6, 2],
    [6, 2, 4, 3, 5, 1],
    [6, 3, 2, 5, 4, 1],
    [6, 4, 5, 2, 3, 1], 
    [6, 5, 3, 4, 2, 1]
]

a = list(map(int,input().split()))
b = list(map(int, input().split()))

d = dict(zip(list(range(1, 7)), a))

ds = []
for pattern in patterns:
    c = [d.get(x) for x in pattern]
    ds.append(c)

if b  in ds:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline


class Dice:
    """
    0:top, 1:south, 2:east, 3:west, 4:north, 5:bottom
    """

    def __init__(self, surfaces):
        self.init_surface = surfaces
        self.surface = surfaces

    def init_dice(self):
        self.surface = self.init_surface

    def roll(self, direction: str):
        if direction == "E":
            self.surface = [self.surface[3], self.surface[1], self.surface[0],
                            self.surface[5], self.surface[4], self.surface[2]]

        elif direction == "N":
            self.surface = [self.surface[1], self.surface[5], self.surface[2],
                            self.surface[3], self.surface[0], self.surface[4]]

        elif direction == "S":
            self.surface = [self.surface[4], self.surface[0], self.surface[2],
                            self.surface[3], self.surface[5], self.surface[1]]

        elif direction == "W":
            self.surface = [self.surface[2], self.surface[1], self.surface[5],
                            self.surface[0], self.surface[4], self.surface[3]]

        return

    def spin(self):
        self.surface = [self.surface[0], self.surface[3], self.surface[1],
                        self.surface[4], self.surface[2], self.surface[5]]
        return

    def get_surface(self, num):
        if num in self.surface:
            indexes = [i for i, x in enumerate(self.surface) if x == num]
            return indexes
        else:
            return None

    def get_top(self):
        return self.surface[0]

    def get_south(self):
        return self.surface[1]

    def get_east(self):
        return self.surface[2]


def main():
    surface = [int(i) for i in input().strip().split()]
    dice1 = Dice(surface)
    surface = [int(i) for i in input().strip().split()]
    dice2 = Dice(surface)

    top1 = dice1.get_top()
    indexes = dice2.get_surface(top1)
    for cur in indexes:
        dice2.init_dice()
        if cur == 0:
            pass
        elif cur == 1:
            dice2.roll("N")
        elif cur == 2:
            dice2.roll("W")
        elif cur == 3:
            dice2.roll("E")
        elif cur == 4:
            dice2.roll("S")
        elif cur == 5:
            dice2.roll("S")
            dice2.roll("S")
        for _ in range(4):
            dice2.spin()
            if dice1.surface == dice2.surface:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
class Dice(object):
    def __init__(self):
        self.number = [0 for _ in range(6)]
        self.before = [0 for _ in range(6)]
        self.init = [0 for _ in range(6)]

    def set_number(self, l):
        for i in range(6):
            self.number[i] = l[i]

    def roll(self, loc):
        d = {
            'N': (1, 5, 2, 3, 0, 4),
            'S': (4, 0, 2, 3, 5, 1),
            'E': (3, 1, 0, 5, 4, 2),
            'W': (2, 1, 5, 0, 4, 3)
        }
        for i in range(6):
            self.before[i] = self.number[i]

        for i, j in enumerate(d[loc]):
            self.number[i] = self.before[j]

    def roll_clockwise(self):
        for i in range(6):
            self.before[i] = self.number[i]
        self.number = [self.before[i] for i in (0, 2, 4, 1, 3, 5)]

    def set_Top_and_Front(self, top, front):
        top_index = self.number.index(top)
        if top_index == 5:
            self.roll('E')
            self.roll('E')
        elif top_index == 4:
            self.roll('S')
        elif top_index == 3:
            self.roll('E')
        elif top_index == 2:
            self.roll('W')
        elif top_index == 1:
            self.roll('N')
        front_index = self.number.index(front)
        if front_index == 1:
            pass
        elif front_index == 2:
            self.roll_clockwise()
        elif front_index == 3:
            self.roll_clockwise()
            self.roll_clockwise()
            self.roll_clockwise()
        elif front_index == 4:
            self.roll_clockwise()
            self.roll_clockwise()

    def set_Top(self, idx):
        if idx == 5:
            self.roll('E')
            self.roll('E')
        elif idx == 4:
            self.roll('S')
        elif idx == 3:
            self.roll('E')
        elif idx == 2:
            self.roll('W')
        elif idx == 1:
            self.roll('N')
        elif idx == 0:
            pass

    def check_identity(self, another_dice):
        res = False

        for i in range(6):
            self.init[i] = self.number[i]

        for i in range(6):
            self.set_Top(i)
            for j in range(4):
                if j == 0:
                    pass
                else:
                    self.roll_clockwise()
                if self.number == another_dice:
                    res = True
                    break
            if res:
                break
            for i in range(6):
                self.number[i] = self.init[i]
        return res


if __name__ == '__main__':
    l = list(map(int, input().split()))
    dice_a = Dice()
    dice_a.set_number(l)
    m = list(map(int, input().split()))
    print('Yes' if dice_a.check_identity(m) else 'No')