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


type Dice = [([String], [String])]

makeDice :: [String] -> Dice
makeDice ls = map f di
  where
    f (xs, ys) = (map (ls' !!) xs, map (ls' !!) ys)
    ls' = "_" : ls
    di = [([1, 6], [5, 3, 2, 4]),
          ([2, 5], [1, 3, 6, 4]),
          ([3, 4], [1, 5, 6, 2]),
          ([4, 3], [1, 2, 6, 5]),
          ([5, 2], [1, 4, 6, 3]),
          ([6, 1], [2, 3, 5, 4])]

makeRotation :: [a] -> [[a]]
makeRotation xs = take 4 $ map (take 4) $ tails (cycle xs)

check :: Dice -> Dice -> Bool
check ds1 ds2
  | null ys       = True
  | otherwise = all (check' ds1) $ take 2 ys
  where
    ys = [x | x@([a, b], _) <- ds2, a /= b]
    check' ds1 (tb, ds)
      | zs == Nothing = False
      | otherwise = elem ds $ makeRotation $ fromJust zs
      where zs = lookup tb ds1


main :: IO ()
main = do
  ds1 <- makeDice . words <$> getLine
  ds2 <- makeDice . words <$> getLine
  putStrLn $ if check ds1 ds2 then "Yes" else "No"

