startWith :: String -> String -> Bool
startWith [] _ = True
startWith _ [] = False
startWith (x:xs) (y:ys) | x /= y = False
                        | otherwise = startWith xs ys

solv' :: Int -> Int-> String -> String -> Bool
solv' i n x y | i > n = False
              | (startWith x y) = True
              | otherwise = solv' (i+1) n x (tail y)

solv :: String -> String -> String
solv x y | solv' 0 (length y) x (y++y) = "Yes"
         | otherwise = "No"

main = do
  r <- getLine
  c <- getLine
  putStrLn $ solv c r