import Control.Applicative

match :: [Int] -> [Int] -> Bool
match xs [a, b, c, d, e, f]
    | xs == [a, b, c, d, e, f] = True
    | xs == [a, d, b, e, c, f] = True
    | xs == [a, e, d, c, b, f] = True
    | xs == [a, c, e, b, d, f] = True
    | otherwise                = False

solve :: [Int] -> [Int] -> Bool
solve xs [a, b, c, d, e, f]
    | match xs [a, b, c, d, e, f] = True
    | match xs [b, c, a, f, d, e] = True
    | match xs [c, a, b, e, f, d] = True
    | match xs [f, d, e, b, c, a] = True
    | match xs [d, e, f, a, b, c] = True
    | match xs [e, f, d, c, a, b] = True
    | otherwise                   = False

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