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

ltable1 [r1, r2, r3, r4, r5, r6] =
  [ (r1, concat (replicate 2 [r2, r3, r5, r4]))
  , (r2, concat (replicate 2 [r6, r3, r1, r4]))
  , (r3, concat (replicate 2 [r6, r5, r1, r2]))
  , (r4, concat (replicate 2 [r6, r2, r1, r5]))
  , (r5, concat (replicate 2 [r6, r4, r1, r3]))
  , (r6, concat (replicate 2 [r5, r3, r2, r4]))
  ]

ltable2 [r1, r2, r3, r4, r5, r6] =
  [ (r1, [r2, r3, r5, r4])
  , (r2, [r6, r3, r1, r4])
  , (r3, [r6, r5, r1, r2])
  , (r4, [r6, r2, r1, r5])
  , (r5, [r6, r4, r1, r3])
  , (r6, [r5, r3, r2, r4])
  ]

ltab1lookup ltab1 (c, lt2lst) = maybe False f $ lookup c ltab1
  where
    f = (lt2lst `isInfixOf`)

showYN True = putStrLn "Yes"
showYN False = putStrLn "No"

main :: IO ()
main = do
  dice1 <- map read . words <$> getLine :: IO [Int]
  dice2 <- map read . words <$> getLine :: IO [Int]
  let ltab1 = ltable1 dice1
  let ltab2 = ltable2 dice2
  showYN $ all (ltab1lookup ltab1) ltab2