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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
}
} 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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
} main {
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	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 char[]ss = S.toCharArray(); ss S.toCharArray() S.toCharArray S char[]t = T.toCharArray(); t T.toCharArray() T.toCharArray T int cou = 0; cou 0 for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    } 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<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    } {
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    } for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        } int j=0; int j=0; j 0 j<T.length() j T.length() T.length T j++ j++ j {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        } {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        } if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        } ss[i] == t[j] ss[i] ss i t[j] t j {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        } if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	} (S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j)) (S.substring(i,S.length()) + S.substring(0,i)) .equals (S.substring(i,S.length()) + S.substring(0,i)) S.substring(i,S.length()) S.substring S i S.length() S.length S S.substring(0,i) S.substring S 0 i T.substring(j,T.length()) + T.substring(0,j) T.substring(j,T.length()) T.substring T j T.length() T.length T T.substring(0,j) T.substring T 0 j {
        		cou++;
        	} cou++ cou if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   } cou > 0 cou 0 {
		System.out.println("Yes");
   } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
	   	System.out.println("No");
   } 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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
}
} Main
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();
    char[]ss = S.toCharArray();
    char[]t = T.toCharArray();

    int cou = 0;
    for(int i=0; i<S.length(); i++){
    	for(int j=0; j<T.length(); j++) {
        if(ss[i] == t[j]) {
        	if((S.substring(i,S.length()) + S.substring(0,i)) .equals (T.substring(j,T.length()) + T.substring(0,j))) {
        		cou++;
        	}
        }
        }
    }
   if(cou > 0) {
		System.out.println("Yes");
   }else {
	   	System.out.println("No");
   }
}
}
