Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

class dice_class:
    def __init__(self, list):
        self.num = list

    def sut(self, top):  #set_up_top
        while True:
            if self.num[0] == top:
                break
            else:
                self.roll('E')
            if self.num[0] == top:
                break
            else:
                self.roll('N')

    def suf(self, front):   #set_up_front
        while True:
            if self.num[1] == front:
                break
            else:
                self.roll('SEN')

    def roll(self, s):
        for i in s:
            if i == 'E':
                self.rollE()
            elif i == 'N':
                self.rollN()
            elif i == 'S':
                self.rollS()
            elif i == 'W':
                self.rollW()

    def rollE(self):
        self.num = [self.num[3], self.num[1], self.num[0], self.num[5], self.num[4], self.num[2]]

    def rollN(self):
        self.num = [self.num[1], self.num[5], self.num[2], self.num[3], self.num[0], self.num[4]]

    def rollS(self):
        self.num = [self.num[4], self.num[0], self.num[2], self.num[3], self.num[5], self.num[1]]

    def rollW(self):
        self.num = [self.num[2], self.num[1], self.num[5], self.num[0], self.num[4], self.num[3]]


if __name__ == "__main__":
    dice1 = dice_class(map(int, raw_input().split()))
    dice2 = dice_class(map(int, raw_input().split()))
    flg = False

    for i in range(6):
        if i % 2:
            dice1.roll('E')
        else:
            dice1.roll('N')
        dice2.sut(dice1.num[0])
        dice2.suf(dice1.num[1])
        if dice1.num == dice2.num:
            flg = True
            break

    if flg:
        print "Yes"
    else:
        print "No"

Fixed submission:
# -*- coding: utf-8 -*-

class dice_class:
    def __init__(self, list):
        self.num = list

    def sut(self, top):  #set_up_top
        i = 0
        while i < 3:
            if self.num[0] == top:
                break
            else:
                self.roll('E')
            if self.num[0] == top:
                break
            else:
                self.roll('N')
            i += 1

    def suf(self, front):   #set_up_front
        i = 0
        while i < 4:
            if self.num[1] == front:
                break
            else:
                self.roll('SEN')
            i += 1

    def roll(self, s):
        for i in s:
            if i == 'E':
                self.rollE()
            elif i == 'N':
                self.rollN()
            elif i == 'S':
                self.rollS()
            elif i == 'W':
                self.rollW()

    def rollE(self):
        self.num = [self.num[3], self.num[1], self.num[0], self.num[5], self.num[4], self.num[2]]

    def rollN(self):
        self.num = [self.num[1], self.num[5], self.num[2], self.num[3], self.num[0], self.num[4]]

    def rollS(self):
        self.num = [self.num[4], self.num[0], self.num[2], self.num[3], self.num[5], self.num[1]]

    def rollW(self):
        self.num = [self.num[2], self.num[1], self.num[5], self.num[0], self.num[4], self.num[3]]


if __name__ == "__main__":
    dice1 = dice_class(map(int, raw_input().split()))
    dice2 = dice_class(map(int, raw_input().split()))
    flg = False

    for i in range(6):
        if i % 2:
            dice1.roll('E')
        else:
            dice1.roll('N')
        dice2.sut(dice1.num[0])
        dice2.suf(dice1.num[1])
        if dice1.num == dice2.num:
            flg = True
            break

    if flg:
        print "Yes"
    else:
        print "No"