import Data.Functor( (<$>))

main = do
    let
	readLine = (read <$>) . words <$> getLine   ::IO [Int]

    d1 <- readLine
    d2 <- readLine
    let
	matchedState dice [top, front]
	  = filter checkFront checkList
	      where
		roll d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
		roll d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
		roll d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
		roll d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]

		rolls d dirs = foldl roll d dirs

		checkTop d = top == head d
		checkFront d = front== d!!1
		rot d = rolls d "ESW"
		candidate = filter checkTop
				[ dice
				, rolls dice "S"
				, rolls dice "SS"
				, rolls dice "SSS"
				, rolls dice "E"
				, rolls dice "EE"
				, rolls dice "EEE"]
		checkList = do
		    c <- candidate
		    [c, rot c, rot.rot $ c, rot.rot.rot $ c]

	identified
	  = case matchedState d2 [d1!!0, d1!!1] of
		[]  -> False
		list -> or $ ((drop 2 d1 ==) . (drop 2)) <$> list

    putStrLn $ if identified then "Yes" else "No"

