#K34317. Circular Equivalence of Binary Strings

    ID: 25283 Type: Default 1000ms 256MiB

Circular Equivalence of Binary Strings

Circular Equivalence of Binary Strings

Given two binary strings S1 and S2, determine whether S2 can be obtained by a cyclic rotation of S1. In other words, check if S2 is a substring of S1 concatenated with itself.

More formally, for two strings S1 and S2 of equal length, S2 is said to be circularly equivalent to S1 if and only if there exists an integer k (0 ≤ k < |S1|) such that:

\[ S_2 = S_1[k:] \; \Vert \; S_1[:k] \]

If the strings have different lengths, they are considered not equivalent.

inputFormat

The input consists of two lines. The first line contains the binary string S1, and the second line contains the binary string S2.

Both strings consist only of the characters '0' and '1'.

outputFormat

Output a single line: YES if the two strings are circularly equivalent; otherwise, output NO.

## sample
11001100
11001100
YES