import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe (fromJust)

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [[Int]] -> String
solve (diceA:diceB:_) =
    let a = solve' diceA 1 2 in
    let b = solve' diceB 1 2 in
    if (a == b) then "Yes" else "No"
    where
    solve' dice upSide foreSide =
        let cmdSet = [(upSide, ["", "N", "W", "E", "S", "NN"]),
                        (foreSide, ["S", "", "NWS", "NES", "NEES", "N"])] in
        let d = foldl' f dice cmdSet in
        d
    f :: Dice -> (Int,[String]) -> Dice
    f dice (side,cmds) =
        let cmd = fromJust . lookup side $ zip dice cmds in
        foldl' rot dice cmd 

main =
    putStrLn =<< solve . map (map read . words) . lines <$> getContents