import Control.Applicative

type Dice    = [(Int, Int)]
type Command = Char

rev :: (a,a) -> (a,a)
rev (x,y) = (y,x)

roll :: Dice -> Command -> Dice
roll [a, b, c] com =
    case com of
        'N' -> [b, rev a, c]
        'E' -> [rev c, b, a]
        'S' -> [rev b, a, c]
        'W' -> [c, b, rev a]
        _   -> error "Invalid command."
roll _ _ = error "Invalid command."

fromList :: [Int] -> Dice
fromList [a, b, c, d, e, f] = [(a, f), (b, e), (c, d)]
fromList _ = error "Invalid dice."

spin :: Dice -> [Dice]
spin [a, b, c] = [ [a, b, c]
                 , [a, rev c, b]
                 , [a, rev b, rev c]
                 , [a, c, rev b]
                 ]
spin _ = error "Invalid dice."

dicePermutation :: Dice -> [Dice]
dicePermutation d = spin d ++ spin d' ++ concatMap (spin  . roll d) "NEWS"
  where d' = roll (roll d 'N') 'N'

equalDice :: Dice -> Dice -> Bool
equalDice d1 d2 = d1 `elem` dicePermutation d2

main :: IO ()
main = do
    d1 <- readDice
    d2 <- readDice
    putStrLn $ if equalDice d1 d2 then "Yes" else "No"
    where readDice = fromList . map read . words <$> getLine