#K15986. Circular Permutations
Circular Permutations
Circular Permutations
Given two strings s1 and s2, determine whether s2 is a circular permutation (i.e., a rotation) of s1. In other words, s2 is a circular permutation of s1 if and only if the following conditions hold:
1. The lengths of s1 and s2 are equal, i.e., $$|s1| = |s2|.$$
2. s2 is a substring of s1+s1. That is, if you concatenate s1 with itself, then s2 should appear as a contiguous sequence within the result.
Example: For s1 = "abcd" and s2 = "dabc", since "dabc" is a substring of "abcdabcd", the answer is True.
inputFormat
The first line of input contains an integer T (the number of test cases). Each of the following T lines contains two space-separated strings s1 and s2.
outputFormat
For each test case, output a single line containing True if s2 is a circular permutation of s1, otherwise output False.
## sample4
abcd dabc
abcd cdab
abcd bcda
abcd abcd
True
True
True
True
</p>