Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-siklik-surilganmi

Cyclic shift?

Medium 1000 ms 128 MB 59%
Share

Two words $s$ and $t$ of the same length are given. Determine whether $t$ can be obtained by a cyclic shift of $s$ — taking several (possibly zero) letters from the beginning and moving them to the end.

A cyclic shift of the characters of a string

Input

The first line contains $s$, the second line $t$.

Output

YES if it is possible, otherwise NO.

Note

$1 \le |s| = |t| \le 5 * 10^{4}$
$s$ and $t$ consist of lowercase Latin letters only

Examples

Input #1
algor
goral
Output #1
YES
Input #2
abc
acb
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.