Олимпиадный тренинг

Задача 38237. Letters in a circle


Задача

Темы: Строки Перебор
Several letters (possibly repeating) are written around the circle. Petya wonders if he will be able to read a certain word if he moves in a circle (in any direction) without missing letters (he can choose where to start and in which direction to move).

Input
The first line contains lowercase Latin letters in the order in which they are arranged in a circle clockwise. Letters are written without spaces, their number is not less than 1 and not more than 100.

The second line contains the word Petya wants to find. It also consists of lowercase Latin letters and has a length from 1 to 100.

Imprint
Print YES in capital Latin letters if such a word can be read moving in a circle, and NO otherwise.
Examples
# Input Output
1 abcdefg
abd
NO
2 abcdg
bag
YES
3 a
aaa
YES