
//不能简单的判断原串相等，后面也得子串和子串
//旋转必定在最后
//abaaabaa与baaabaaa
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					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.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					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.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
		
		
		
	} main {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
		
		
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.nextLine(); S sc.nextLine() sc.nextLine sc String T = sc.nextLine(); T sc.nextLine() sc.nextLine sc int k = 0; k 0 int j = 0; j 0 if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		} S.equals(T) S.equals S T {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		} for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			} int i = 0; int i = 0; i 0 i <= S.length() i S.length() S.length S i++ i++ i {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			} {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			} String a = S.substring(0, i); a S.substring(0, i) S.substring S 0 i if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				} !T.contains(a) T.contains(a) T.contains T a {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				} j = i - 1 j i - 1 i 1 k = T.lastIndexOf(a.substring(0,i-1)) k T.lastIndexOf(a.substring(0,i-1)) T.lastIndexOf T a.substring(0,i-1) a.substring a 0 i-1 i 1 break; if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			} k==0||k==-1 k==0 k 0 k==-1 k -1 1 {
				System.out.println("No");
			} System.out.println("No") System.out.println System.out System System.out "No" {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			} if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				} T.substring(0,k).equals(S.substring(j,S.length())) T.substring(0,k).equals T.substring(0,k) T.substring T 0 k S.substring(j,S.length()) S.substring S j S.length() S.length S {
					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.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					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.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
		
		
		
	}

} Main

//不能简单的判断原串相等，后面也得子串和子串
//旋转必定在最后
//abaaabaa与baaabaaa
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		int k = 0;
		int j = 0;
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			for (int i = 0; i <= S.length(); i++) {
				String a = S.substring(0, i);
				if(!T.contains(a)) {
					j = i - 1;
					k = T.lastIndexOf(a.substring(0,i-1));
					break;
				}
			}
			if(k==0||k==-1) {
				System.out.println("No");
			}else {
				//System.out.println(T.substring(0,k));
				//System.out.println(S.substring(j,S.length()-1));
				if(T.substring(0,k).equals(S.substring(j,S.length()))) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
		
		
		
	}

}
