    import java.util.Arrays;
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    } import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    } Main public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	} main {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc String T = sc.next(); T sc.next() sc.next sc String Ss[] = S.split(""); Ss S.split("") S.split S "" String Ts[] = T.split(""); Ts T.split("") T.split T "" String tmpS[] = S.split(""); tmpS S.split("") S.split S "" for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		} int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		} { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		} for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			} int j = 0; int j = 0; j 0 j < S.length() j S.length() S.length S j++ j++ j {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			} {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			} if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				} j != S.length() - 1 j S.length() - 1 S.length() S.length S 1 {
    					tmpS[j + 1] = Ss[j];
    				} tmpS[j + 1] = Ss[j] tmpS[j + 1] tmpS j + 1 j 1 Ss[j] Ss j {
    					tmpS[0] = Ss[j];
    				} tmpS[0] = Ss[j] tmpS[0] tmpS 0 Ss[j] Ss j for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			} int j = 0; int j = 0; j 0 j < S.length() j S.length() S.length S j++ j++ j {
    				Ss[j] = tmpS[j];
    			} {
    				Ss[j] = tmpS[j];
    			} Ss[j] = tmpS[j] Ss[j] Ss j tmpS[j] tmpS j if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			} Arrays.equals(tmpS, Ts) Arrays.equals Arrays tmpS Ts {
    				System.out.println("Yes");
    				return;
    			} System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    } public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    } Main
    import java.util.Arrays;
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		
    		String S = sc.next();
    		String T = sc.next();
    		
    		String Ss[] = S.split("");
    		String Ts[] = T.split("");
    		
    		String tmpS[] = S.split("");
    		
    		for (int i = 0; i < S.length(); i++) { 
            
    			for (int j = 0; j < S.length(); j++) {
    				
    				if (j != S.length() - 1){
    					tmpS[j + 1] = Ss[j];
    				} else {
    					tmpS[0] = Ss[j];
    				}
    				
    				
    			}
    			
    			for (int j = 0; j < S.length(); j++) {
    				Ss[j] = tmpS[j];
    			}
    			
    			if (Arrays.equals(tmpS, Ts)) {
    				System.out.println("Yes");
    				return;
    			}

    		}
    		
    		System.out.println("No");
    		
    		
    	}
    }