import Control.Monad
import Data.List

data Eyes = Same | Reverse | Different deriving (Eq)

same_dice :: [Int] -> [Int] -> String
same_dice arr1 arr2 = if any (==(Different :: Eyes)) coincideList
then "No"
else if (mod (count Same coincideList 0) 2) == 0
then "No"
else "Yes"
  where coincideList = zipWith coincide (bothSidesList arr1) (bothSidesList arr2)

count :: (Eq a) => a -> [a] -> Int -> Int
count a [] n = n
count a [x] n = if a == x then (n+1) else n
count a (x:xs) n = if a == x then (count a xs (n+1)) else (count a xs n)

bothSidesList :: [Int] -> [(Int, Int)]
bothSidesList a = zip (fst $ splitAt halfSize a) (reverse $ snd $ splitAt halfSize a)
  where halfSize = (length a) `div` 2

coincide :: (Int, Int) -> (Int, Int) -> Eyes
coincide a b
  | a == b = Same
  | fst a == snd b && snd a == fst b = Reverse
  | otherwise = Different

main = do
  line1 <- getLine :: IO String
  let arr1 = map read (words line1) :: [Int]
  line2 <- getLine :: IO String
  let arr2 = map read (words line2) :: [Int]
  putStrLn $ same_dice arr1 arr2 