import java.util.*;
import java.io.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	}

} import java.util.*; util.* java import java.io.*; io.* java class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	} main {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	} Scanner as = new Scanner(System.in); as new Scanner(System.in) String s; s String p; p String str; str int j = 0; j 0 int count = 0; count 0 int test = 0; test 0 char sli[]; sli char pli[]; pli s = as.nextLine() s as.nextLine() as.nextLine as p = as.nextLine() p as.nextLine() as.nextLine as s = s+s s s+s s s sli = new char[s.length()] sli new char[s.length()] s.length() s.length s pli = new char[p.length()] pli new char[p.length()] p.length() p.length p for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        } {      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        } sli[i] = s.charAt(i) sli[i] sli i s.charAt(i) s.charAt s i for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		} int i=0; int i=0; i 0 i<p.length() i p.length() p.length p i++ i++ i {      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		} {      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		} pli[i] = p.charAt(i) pli[i] pli i p.charAt(i) p.charAt p i for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        } int i=0; int i=0; i 0 i<(s.length()/2) i (s.length()/2) s.length() s.length s 2 i++ i++ i {      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        } {      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        } for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			} j=0; j=0 j 0 j<p.length() j p.length() p.length p j++ j++ j {
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			} {
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			} if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				} sli[j+i] == pli[j] sli[j+i] sli j+i j i pli[j] pli j {
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				} count++ count {
					
					count = 0;
				
				} count = 0 count 0 if(count == p.length()){
				
				break;
				
			} count == p.length() count p.length() p.length p {
				
				break;
				
			} break; count = 0 count 0 if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		} count == p.length() count p.length() p.length p {
			
			str = "Yes";
			System.out.println(str);
			
		} str = "Yes" str "Yes" System.out.println(str) System.out.println System.out System System.out str {
			
			str = "No";
			System.out.println(str);
			
		} str = "No" str "No" System.out.println(str) System.out.println System.out System System.out str String[] args args
import java.util.*;
import java.io.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	}

}