import Control.Applicative

type Dice
    = [Int]

type Problem
    = (Dice, Dice)

type Result
    = Bool

roll :: Dice -> String -> Dice

roll dice []
    = dice

roll [s1, s2, s3, s4, s5, s6] (x:xs)
    = case x of
        'N' -> roll [s2, s6, s3, s4, s1, s5] xs
        'S' -> roll [s5, s1, s3, s4, s6, s2] xs
        'E' -> roll [s4, s2, s1, s6, s5, s3] xs
        'W' -> roll [s3, s2, s6, s1, s5, s4] xs
        'C' -> roll [s1, s3, s5, s2, s4, s6] xs
        
rollTo :: Int -> Dice -> [Dice]

rollTo top dice@[s1, s2, s3, s4, s5, s6]
    = [rolled | (cond, rolled) <- [c1, c2, c3, c4, c5, c6], top == cond] where
        c1 = (s1, dice)
        c2 = (s2, roll dice "N")
        c3 = (s3, roll dice "W")
        c4 = (s4, roll dice "E")
        c5 = (s5, roll dice "S")
        c6 = (s6, roll dice "NN")
        
spinTo :: Int -> Dice -> [Dice]

spinTo front dice@[_, s2, s3, s4, s5, _]
    = [spun | (cond, spun) <- [c2, c3, c4, c5], front == cond] where
        c2 = (s2, dice)
        c3 = (s3, roll dice "C")
        c4 = (s4, roll dice "CCC")
        c5 = (s5, roll dice "CC")

solve :: Problem -> Result

solve (dice1@(top:front:_), dice2)
    = elem dice1 $ concatMap (spinTo front) $ rollTo top dice2

output :: Result -> String

output bool
    = if bool then "Yes" else "No"
    
input :: IO Problem

input
    = do
        dice1 <- map read <$> words <$> getLine
        dice2 <- map read <$> words <$> getLine
        return (dice1, dice2)

main :: IO ()

main
    = putStrLn <$> output =<< solve <$> input