import Control.Monad
import Control.Applicative
import Data.List

data Dice = Dice{tp::Int, fr::Int, rt::Int, lt::Int, bk::Int, bm::Int} deriving (Show, Eq)

roll :: Dice -> Char -> Dice
roll (Dice tp fr rt lt bk bm) dir
  | dir == 'N' = Dice fr bm rt lt tp bk
  | dir == 'S' = Dice bk tp rt lt bm fr
  | dir == 'E' = Dice lt fr tp bm bk rt
  | dir == 'W' = Dice rt fr bm tp bk lt
  | otherwise = Dice tp fr rt lt bk bm

rolls :: Dice -> String -> Dice
rolls d s = foldl roll d s

initDice :: [Int] -> Dice
initDice (tp:fr:rt:lt:bk:bm:_) = Dice tp fr rt lt bk bm

setDice :: Dice -> Int -> Int -> Dice
setDice d t f = d2
  where
    d1 = head . filter (\x -> tp x == t) $ scanl roll d "NENEN"
    d2 = if null d2s then initDice (repeat (-1)) else head d2s
    d2s = filter (\x -> fr x == f) $ scanl rolls d1 ["NES","NES","NES"]

main = do
  xs <- map read . words <$> getLine :: IO [Int]
  ys <- map read . words <$> getLine :: IO [Int]
  putStrLn $ solve xs ys

solve :: [Int] -> [Int] -> String
solve xs ys
  | d1 == d2 = "Yes"
  | otherwise = "No"
  where d1 = initDice xs
        d2 = setDice (initDice ys) (tp d1) (fr d1)