module Main where

import Data.Bool
import Data.Functor
import Data.List
import Data.Maybe

getDice :: IO Dice
getDice = toDice . map read . words <$> getLine

toDice :: [Int] -> Dice
toDice [u,v,w,x,y,z] = (u,v,w,x,y,z)

main :: IO ()
main = do
  { d1 <- getDice
  ; d2 <- getDice
  ; putStrLn $ bool "No" "Yes" (d1 `elem` trans d2)
  }
type Dice = (Int,Int,Int,Int,Int,Int)

updowns :: Dice -> [Dice]
updowns d@(t,s,e,w,n,b) = [d,(b,s,w,e,n,t)]

spins d@(t,s,e,w,n,b) = [d,(s,w,b,t,e,n),(w,t,n,s,b,e)]

rots :: Dice -> [Dice]
rots d@(t,s,e,w,n,b) = [d,(t,e,n,s,w,b),(t,n,w,e,s,b),(t,w,s,n,e,b)]

trans :: Dice -> [Dice]
trans = concatMap rots . concatMap spins . updowns