module Main where

import Data.Bool
import Data.Functor
import Data.List
import Data.Maybe

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { xs <- getInts
  ; ys <- getInts
  ; putStrLn $ bool "No" "Yes" $ sameDice xs ys
  }

sameDice :: [Int] -> [Int] -> Bool
sameDice xs ys = let
  { yifs = zip [1..] ys; yfis = zip ys [1..]
  ; cs = checkItems xs
  } in sort xs == sort ys && all (check yifs yfis) cs

check :: [(Int,Int)] -> [(Int,Int)] -> (Int,Int,Int) -> Bool
check ifs fis (x,y,z) = case lookup x fis of
  Nothing -> False
  Just x' -> case lookup y fis of
    Nothing -> False
    Just y' -> case east (x',y') of
      Nothing -> False
      Just e -> case lookup e ifs of
        Nothing -> False
        Just z' -> z == z'

checkItems :: [Int] -> [(Int,Int,Int)]
checkItems [t,s,e,w,n,b]
  = [(t,s,e),(t,e,n),(t,n,w),(t,w,s)]

east :: (Int,Int) -> Maybe Int
east (1,2) = Just 3
east (1,3) = Just 5
east (1,4) = Just 2
east (1,5) = Just 4
east (2,1) = Just 4
east (2,3) = Just 1
east (2,4) = Just 6
east (2,6) = Just 3
east (3,1) = Just 2
east (3,2) = Just 6
east (3,5) = Just 1
east (3,6) = Just 5
east (4,1) = Just 5
east (4,2) = Just 1
east (4,5) = Just 6
east (4,6) = Just 2
east (5,1) = Just 3
east (5,3) = Just 6
east (5,4) = Just 1
east (5,6) = Just 4
east (6,2) = Just 4
east (6,3) = Just 2
east (6,4) = Just 5
east (6,5) = Just 3
east _     = Nothing