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] (char:string)
    = case char of
        'N' -> roll [s2, s6, s3, s4, s1, s5] string
        'S' -> roll [s5, s1, s3, s4, s6, s2] string
        'E' -> roll [s4, s2, s1, s6, s5, s3] string
        'W' -> roll [s3, s2, s6, s1, s5, s4] string
        'C' -> roll [s1, s3, s5, s2, s4, s6] string

equal :: Dice -> Dice -> Bool

equal dice1 dice2
    = and $ zipWith (==) dice1 dice2
    
rollTo :: Int -> Dice -> [Dice]

rollTo s dice@[s1, s2, s3, s4, s5, s6]
    = filter (/= []) [case1, case2, case3, case4, case5, case6] where
        case1 = if s == s1 then roll dice "" else []
        case2 = if s == s2 then roll dice "N" else []
        case3 = if s == s3 then roll dice "W" else []
        case4 = if s == s4 then roll dice "E" else []
        case5 = if s == s5 then roll dice "S" else []
        case6 = if s == s6 then roll dice "NN" else []
        
spinTo :: Int -> Dice -> [Dice]

spinTo s dice@[_, s2, s3, s4, s5, _]
    = filter (/= []) [case2, case3, case4, case5] where
        case2 = if s == s2 then roll dice "" else []
        case3 = if s == s3 then roll dice "C" else []
        case4 = if s == s4 then roll dice "CCC" else []
        case5 = if s == s5 then roll dice "CC" else []

solve :: Problem -> Result

solve (dice1@(top:front:_), dice2)
    = any (equal dice1) spuns where
        rolleds = rollTo top dice2
        spuns = concatMap (spinTo front) rolleds

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