Easy Beginners Problems > Ad-hoc

Give two string T and S. Take a decision whether T is a cyclic string of S or not . For example abc and bca are two cyclic strings of one another. If we rotate abc for one time we get cab . Then again rotate cab and we get bca. That’s why abc and bca are two cyclic string of each other. But abc and bac are not cyclic string of each other. [Rotate means move the last character to first position of a string] Input: ------ At first gives you an integer **T (T<=10)**, is the number of test cases. Each case gives two strings T and **S ( 1<=T,S<=1000000 )** in two separated lines. Output: ------- Output **“YES”** if T is a cyclic string of S, otherwise output **“NO”**. Sample Input ------------ 2 abc bca abc bcd Sample Output ------------- YES NO *Look, For Test Case – 1 , if we rotate abc we will get abc -> cab -> bca . For Test Case – 2 , character d is not present in abc. So abc and bcd are not cyclic string of each other.*

Rajon Bardhan