matchString :: String -> String -> Bool
matchString [] _  = False
matchString s@(x:xs) p@(y:_)
  | x == y && match s p = True
  | otherwise           = matchString xs p
  where
      match :: String -> String -> Bool
      match _ [] = True
      match [] _ = False
      match (x:xs) (y:ys)
        | x == y    = match xs ys
        | otherwise = False

main :: IO ()
main = do
    s <- getLine
    p <- getLine
    if matchString (s++s) p then putStrLn "Yes" else putStrLn "No"

