import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Maybe          (fromJust)

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

rollH :: Dice -> [Dice]
rollH d = d : take 3 (iterate f d)
  where
    f (Dice ds) = Dice [ds !! (i-1) | i <- [1,4,2,5,3,6]]

rollTop :: Int -> Dice -> Dice
rollTop 0 ds = ds
rollTop 1 ds = roll 'N' ds
rollTop 2 ds = roll 'W' ds
rollTop 3 ds = roll 'E' ds
rollTop 4 ds = roll 'S' ds
rollTop 5 ds = roll 'S' $ roll 'S' ds

main :: IO ()
main = do
    d1 <- fmap read . words <$> getLine :: IO [Int]
    d2 <- fmap read . words <$> getLine :: IO [Int]
    let (Just top) = (head d1) `elemIndex` d2
    let cs = rollH $ rollTop top dice
    let a = filter (\(Dice ds) -> d1 == map (d2 !!) ds) cs
    if null a
       then putStrLn "No"
       else putStrLn "Yes"

