Orthogonal Closure

Time limit2sMemory limit64 MB

Problem

The orthogonal sum of two binary strings $a$ and $b$ of equal length $n$ is the string $c$ defined by $c_i = a_i \oplus b_i$, where $\oplus$ is the exclusive OR (it yields $0$ for equal characters and $1$ otherwise).

For a binary string $S$ of length $n$, let $S(k)$ denote the $k$-th circular shift of $S$: the operation that moves the last $k$ characters of $S$ to its front. For example, the 2nd circular shift of abcde is deabc.

The orthogonal closure of $S$, written $S^{\oplus}$, is the set of all strings $S(k) \oplus S(l)$ for $0 \le k, l \le n - 1$.

Given a binary string $T$ of the same length $n$, determine whether $T$ belongs to $S^{\oplus}$.

Input

The first line contains the string $T$. The second line contains the string $S$. Both strings have the same length, between $1$ and $5000$, and consist only of the characters 0 and 1.

Output

Print Yes if $T$ belongs to $S^{\oplus}$, and No otherwise.