Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Ring

Write a program which finds a pattern $p$ in a ring shaped text $s$.

Input

In the first line, the text $s$ is given.

In the second line, the pattern $p$ is given.

Output

If $p$ is in $s$, print Yes in a line, otherwise No.

Constraints

$1 \leq $ length of $p \leq $ length of $s \leq 100$

$s$ and $p$ consists of lower-case letters

Sample Input 1

vanceknowledgetoad
advance

Sample Output 1

Yes

Sample Input 2

vanceknowledgetoad
advanced

Sample Output 2

No

Solution in JAVA (judge verdict: Accepted)

import java.util.Scanner;                      


class Main {



	public static void main(String[] args) {   

		Scanner scanner = new Scanner(System.in);


			String s= scanner.nextLine();//文字列sの入力
			String p= scanner.nextLine();//文字列pの入力
			
		
			char[] chars; 
			chars=new char[s.length()];//文字列sを格納する配列chars
			String[] Strings;
			Strings=new String[s.length()];
			String compare="";//文字列pと比較する変数
			boolean anther =false; 
			
			for(int i=0;i < s.length();i++){//桁数分くりかえす
				chars[i]=s.charAt(i);//文字列を1文字ずつ配列に格納
				Strings[i]=String.valueOf(chars[i]);//String型に変換
			}

			int loop=0;//ループを制御する変数
			for(int i =0;i<s.length();i++){
				loop=i;
			for(int ii=i;ii<p.length()+i;ii++){
				 
				
				if(loop == s.length()){
					loop=0;
				}
				
				compare = compare.concat(Strings[loop]);	
				
				loop=loop+1;
				
				if(compare.equals(p)){
					anther=true;
				}
				
				}
			compare="";
			}
				if(anther){
					System.out.println("Yes");
				}
				
				else{
					System.out.println("No");
				}


		scanner.close();


	}
}