import Control.Monad
import Control.Applicative

data Op = S | E | N | W deriving (Show, Eq, Enum)

fromChar c | c == 'S' = S
           | c == 'E' = E
           | c == 'N' = N
           | c == 'W' = W
           | otherwise = error $ "Invalid char " ++ [c]

fromString [] = []
fromString (x:xs) = (fromChar x):(fromString xs)

data Dice = Dice { top :: Int, front :: Int, right :: Int, left :: Int, back :: Int, bottom :: Int }
  deriving (Show, Eq)

makeDice [t, f, r, l, ba, bo] = Dice t f r l ba bo

roll (Dice t f r l ba bo) S = Dice ba t r l bo f
roll (Dice t f r l ba bo) N = Dice f bo r l t ba
roll (Dice t f r l ba bo) E = Dice l f t bo ba r
roll (Dice t f r l ba bo) W = Dice r f bo t ba l
rolls = foldl roll :: Dice -> [Op] -> Dice

equal dice1 dice2 = foldr (||) False [(> 0) $ length $ filter (\x -> x == dice2) $ scanl rolls d [[N, E, S], [N, E, S], [N, E, S]] | d <- ds]
  where ds = scanl roll dice1 [N, E, N, E, N]

solve [x,y] | equal x y = "Yes"
            | otherwise = "No"

main = do
  dices <- map (makeDice . map read . words) <$> replicateM 2 getLine :: IO [Dice]
  putStrLn . solve $ dices


