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

type Dice=[Int]

rotate:: Dice -> Char -> Dice
rotate [u,f,r,l,b,d] 'E' = [l,f,u,d,b,r]
rotate [u,f,r,l,b,d] 'N' = [f,d,r,l,u,b]
rotate [u,f,r,l,b,d] 'S' = [b,u,r,l,d,f]
rotate [u,f,r,l,b,d] 'W' = [r,f,d,u,b,l]
rotate xs _              = xs

search :: [Dice]->[Dice]->Dice->Bool
search dices searched target
  | null dices =  False
  | not $ null found = True
  | otherwise = search next (searched ++ dices) target
  where
    found = [dice | dice<-dices, dice == target]
    next = filter (`notElem` searched) [rotate d opt | d <-dices, opt<-"ENSW" ]

main :: IO ()
main = do
  dice1 <- map read . words <$> getLine
  dice2 <- map read . words <$> getLine
  putStrLn $ if search [dice1] [] dice2 then "Yes" else "No"
