class dise:
    def __init__(self, label):
        self.label1 = label[0]
        self.label2 = label[1]
        self.label3 = label[2]
        self.label4 = label[3]
        self.label5 = label[4]
        self.label6 = label[5]
    
    def N_rotation(self):
        reg = self.label1
        self.label1 = self.label2
        self.label2 = self.label6
        self.label6 = self.label5
        self.label5 = reg
        
    def E_rotation(self):
        reg = self.label1
        self.label1 = self.label4
        self.label4 = self.label6
        self.label6 = self.label3
        self.label3 = reg
        
    def S_rotation(self):
        reg = self.label1
        self.label1 = self.label5
        self.label5 = self.label6
        self.label6 = self.label2
        self.label2 = reg
        
    def W_rotation(self):
        reg = self.label1
        self.label1 = self.label3
        self.label3 = self.label6
        self.label6 = self.label4
        self.label4 = reg
    
    def right_rotation(self):
        reg = self.label2
        self.label2 = self.label3
        self.label3 = self.label5
        self.label5 = self.label4
        self.label4 = reg
    
'''
    def search(self, other_dise):
        count = 0
        while True:
            count += 1
            self.N_rotation()
            if other_dise[0] == self.label1:
                break
            self.E_rotation()
            if other_dise[0] == self.label1:
                break
            if count == 6:
                print("No")
                break

            count = 0            
        while True :
            count += 1
            self.right_rotation()
            if other_dise[1] == self.label2 and other_dise[2] == self.label3 and other_dise[3] == self.label4 and other_dise[4] == self.label5:
                print("Yes")
                break
            if count == 4:
                print("No")
                break
'''
#init_dise = input().split()
#times = int(input())
#print("a")
dise1 = dise(input().split())
dise2 = dise(input().split())
flag = 0

for i in range(3):
    dise1.N_rotation()
    if dise1.label1 == dise2.label1 and dise1.label6 == dise2.label6 :
        for j in range(4):
            dise1.right_rotation()
            if dise1.label2 == dise2.label2 and dise1.label3 == dise2.label3 and dise1.label4 == dise2.label4 and dise1.label5 == dise2.label5:
                flag = 1
                break
    dise1.E_rotation()
    if dise1.label1 == dise2.label1 and dise1.label6 == dise2.label6 :
        for j in range(4):
            dise1.right_rotation()
            if dise1.label2 == dise2.label2 and dise1.label3 == dise2.label3 and dise1.label4 == dise2.label4 and dise1.label5 == dise2.label5:
                flag = 1
                break
    
            
            
if flag == 1:
    print("Yes")
elif flag == 0:
    print("No")

#dise1.search(dise2)



'''
class dise:
    def __init__(self, label):
        self.label1 = label[0]
        self.label2 = label[1]
        self.label3 = label[2]
        self.label4 = label[3]
        self.label5 = label[4]
        self.label6 = label[5]
    
    def N_rotation(self):
        reg = self.label1
        self.label1 = self.label2
        self.label2 = self.label6
        self.label6 = self.label5
        self.label5 = reg
        
    def E_rotation(self):
        reg = self.label1
        self.label1 = self.label4
        self.label4 = self.label6
        self.label6 = self.label3
        self.label3 = reg
        
    def S_rotation(self):
        reg = self.label1
        self.label1 = self.label5
        self.label5 = self.label6
        self.label6 = self.label2
        self.label2 = reg
        
    def W_rotation(self):
        reg = self.label1
        self.label1 = self.label3
        self.label3 = self.label6
        self.label6 = self.label4
        self.label4 = reg
    
    def right_rotation(self):
        reg = self.label2
        self.label2 = self.label3
        self.label3 = self.label5
        self.label5 = self.label4
        self.label4 = reg
    

    def search(self, other_dise):
        count = 0
        while True:
            count += 1
            self.N_rotation()
            if other_dise[0] == self.label1:
                break
            self.E_rotation()
            if other_dise[0] == self.label1:
                break
            if count == 6:
                print("No")
                break

            count = 0            
        while True :
            count += 1
            self.right_rotation()
            if other_dise[1] == self.label2 and other_dise[2] == self.label3 and other_dise[3] == self.label4 and other_dise[4] == self.label5:
                print("Yes")
                break
            if count == 4:
                print("No")
                break
#init_dise = input().split()
#times = int(input())

dise1 = dise(input().split())
dise2 = dise(input().split())

for i in range(6):
    if dise1.label1 == dise2.label1 and dise1.label6 == dise2.label6 :
        for j in range(4):
            dise1.right_rotation()
            if dise1.label2 == dise2.label2 and dise1.label3 == dise2.label3 and dise1.label4 == dise2.label4 and dise1.label5 == dise2.label5:
                print("Yes")
                break
            if i == 3:
            

dise1.search(dise2)
'''

Measured memory_bytes: 7680