import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;
public class Main {
	static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
	static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	}
} Main static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	} check {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	} if(a.length() != b.length())return false; a.length() != b.length() a.length() a.length a b.length() b.length b return false; false for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		} int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i ++ i ++ i {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		} {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		} if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			} a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b) a.charAt(i) == b.charAt(0) a.charAt(i) a.charAt a i b.charAt(0) b.charAt b 0 (a.substring(i, a.length()) + a.substring(0, i)).equals(b) (a.substring(i, a.length()) + a.substring(0, i)).equals (a.substring(i, a.length()) + a.substring(0, i)) a.substring(i, a.length()) a.substring a i a.length() a.length a a.substring(0, i) a.substring a 0 i b {
				return true;
			} return true; true return false; false String a a String b b public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	} main {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String a = in.nextLine(); a in.nextLine() in.nextLine in String b = in.nextLine(); b in.nextLine() in.nextLine in System.out.println(check(a,b) ? "Yes" : "No") System.out.println System.out System System.out check(a,b) ? "Yes" : "No" check(a,b) check a b "Yes" "No" String[] args args public class Main {
	static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	}
} public class Main {
	static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;
public class Main {
	static boolean check(String a,String b) {
		if(a.length() != b.length())return false;
		for(int i = 0;i < a.length();i ++) {
			if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
				return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.nextLine();
		String b = in.nextLine();
		System.out.println(check(a,b) ? "Yes" : "No");
	}
}
