import Data.List

{- Naive Algorithm:  Time Complexity: O(n*m) -}
as `isSubstringOf` bs = any (as `isPrefixOf`) (tails bs)

{-
The implementation of famous KMP Algorithm is from the following link.
https://www.twanvl.nl/blog/haskell/Knuth-Morris-Pratt-in-Haskell
Time complexity: O(n+m)
-}

data KMP a = KMP
      { done :: Bool
      , next :: (a -> KMP a)
      }

isSubstringOf2 :: Eq a => [a] -> [a] -> Bool
isSubstringOf2 as bs = match (makeTable as) bs
   where  match table []     = done table
          match table (b:bs) = done table || match (next table b) bs

isSubstringOf3 :: Eq a => [a] -> [a] -> Bool
isSubstringOf3 as bs = any done $ scanl next (makeTable as) bs

makeTable :: Eq a => [a] -> KMP a
makeTable xs = table
   where table = makeTable' xs (const table)

makeTable' []     failure = KMP True failure
makeTable' (x:xs) failure = KMP False test
   where  test  c = if c == x then success else failure c
          success = makeTable' xs (next (failure x))

main = do
  p<-getLine
  s<-getLine
  putStrLn (if (s `isSubstringOf3` (p ++ p))  then "Yes" else "No")