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

outer (a1:a2:a3:_) (b1:b2:b3:_) = [a2*b3-a3*b2,a3*b1-a1*b3,a1*b2-a2*b1]
inner a b = sum$zipWith(*) a b

-- TSEWNB
-- TB SN EW 
main = do
    let normal = [[1,0,0],[0,1,0],[0,0,1],[0,0,-1],[0,-1,0],[-1,0,0]]
    l1 <- words <$> getLine
    l2 <- words <$> getLine
    let i = map(\w -> let (Just a) = elemIndex(w) l2 in a) l1
    let z = [inner (outer (normal!!a) (normal!!b)) (normal!!c) == inner (outer (normal!!(i!!a)) (normal!!(i!!b))) (normal!!(i!!c)) | a <- [0..3], b <- [a..4], c <- [b..5]]
    let r = if foldr(&&) True z then "Yes" else "No"
    putStrLn $ r