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

perm :: [Int] -> [a] -> [a]
perm y x = [ x!!i | i <- y ]
hRoll = [0,2,4,1,3,5]
toTop = [[0,1,2,3,4,5]
        ,[1,5,2,3,0,4]
        ,[2,1,5,0,4,3]
        ,[3,1,0,5,4,2]
        ,[4,0,2,3,5,1]
        ,[5,1,3,2,4,0]]
hRotate :: [a] -> [[a]]
hRotate d = [d, h d, (h.h) d, (h.h.h) d] where h = (perm hRoll)

allRotate :: [a] -> [[a]]
allRotate d = concat[ hRotate x | x <- map(\ x -> perm x d) toTop]

-- TSEWNB
main = do
    l1 <- words <$> getLine
    l2 <- words <$> getLine
    let o = case elemIndex l1 (allRotate l2) of
              Nothing -> "No"
              _ -> "Yes"
    putStrLn $ o