import Data.List

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

all_pattern_3 :: [a] -> [[a]]
all_pattern_3 ls = [[ls!!0, ls!!1, ls!!2],
                    [ls!!0, ls!!2, ls!!1],
                    [ls!!1, ls!!0, ls!!2],
                    [ls!!1, ls!!2, ls!!0],
                    [ls!!2, ls!!0, ls!!1],
                    [ls!!2, ls!!1, ls!!0]]

same_dice :: [Int] -> [Int] -> String
same_dice arr1 arr2 = if same_dice_both_sides_list (bothSidesList arr1) (all_pattern_3 (bothSidesList arr2))
                      then "Yes"
                      else "No"

same_dice_both_sides_list :: [(Int, Int)] -> [[(Int, Int)]] -> Bool
same_dice_both_sides_list _ [] = False
same_dice_both_sides_list ls1 (ls2:ls_all) = same_dice_both_side ls1 ls2 || same_dice_both_sides_list ls1 ls_all

same_dice_both_side :: [(Int, Int)] -> [(Int, Int)] -> Bool
same_dice_both_side ls1 ls2 = if any (==(Different :: Eyes)) coincideList
then False
else if mod (count Same coincideList 0) 2 == 0
then False
else True
  where coincideList = zipWith coincide ls1 ls2

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 