import Data.List

toDice :: [Int]	-> [[Int]]
toDice [a,b,c,d,e,f] = [[a,f],[b,e],[c,d]]

pattern1 :: [Int] -> [String]
pattern1 x = map show [(x !! 0),(x !! 1),(x !! 5),(x !! 4),(x !! 0)]

pattern2 :: [Int] -> [String]
pattern2 x = map show [(x !! 1),(x !! 2),(x !! 4),(x !! 3),(x !! 1)]

pattern3 :: [Int] -> [String]
pattern3 x = map show [(x !! 2),(x !! 0),(x !! 3),(x !! 5),(x !! 2)]

solve :: [Int] -> String -> Int
solve list x
  | isInfixOf x (unwords $ pattern1 list) = list !! 2
  | isInfixOf x (unwords $ pattern2 list) = list !! 0
  | isInfixOf x (unwords $ pattern3 list) = list !! 1
  | isInfixOf x (unwords $ reverse $ pattern1 list) = list !! 3
  | isInfixOf x (unwords $ reverse $ pattern2 list) = list !! 5
  | isInfixOf x (unwords $ reverse $ pattern3 list) = list !! 4

check1 :: [Int] -> [Int] -> Bool
check1 xs ys = (solve' xs) == (solve' ys)
  where solve' = sort . map sort . toDice

check2 :: [Int] -> [Int] -> String -> Bool
check2 xs ys s = (solve xs s) == (solve ys s)

main = getContents >>= putStrLn . (\x -> if and x then "Yes" else "No") . (\[a,b] -> check2 (read' a) (read' b) (mkstr a) : check1 (read' a) (read' b) : []) . lines
  where read' = map read . words
        mkstr = unwords . map show . take 2 . read'