import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr1 = str.toCharArray();
		str = br.readLine();
		char[] cr2 = str.toCharArray();
		String dis = "No";
		int x;
		for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		}
		System.out.println(dis);
	}
} import java.io.*; io.* java class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr1 = str.toCharArray();
		str = br.readLine();
		char[] cr2 = str.toCharArray();
		String dis = "No";
		int x;
		for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		}
		System.out.println(dis);
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr1 = str.toCharArray();
		str = br.readLine();
		char[] cr2 = str.toCharArray();
		String dis = "No";
		int x;
		for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		}
		System.out.println(dis);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr1 = str.toCharArray();
		str = br.readLine();
		char[] cr2 = str.toCharArray();
		String dis = "No";
		int x;
		for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		}
		System.out.println(dis);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br char[] cr1 = str.toCharArray(); cr1 str.toCharArray() str.toCharArray str str = br.readLine() str br.readLine() br.readLine br char[] cr2 = str.toCharArray(); cr2 str.toCharArray() str.toCharArray str String dis = "No"; dis "No" int x; x for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		} int i=0; int i=0; i 0 i<cr1.length i cr1.length cr1 cr1.length i++ i++ i {
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		} {
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		} if(dis.equals("Yes")) break; dis.equals("Yes") dis.equals dis "Yes" break; if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			} cr1[i]==cr2[0] cr1[i] cr1 i cr2[0] cr2 0 {
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			} dis = "Yes" dis "Yes" x = i x i for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				} int j=1; int j=1; j 1 j<cr2.length j cr2.length cr2 cr2.length j++ j++ j {
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				} {
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				} x++ x if(x == cr1.length) x=0; x == cr1.length x cr1.length cr1 cr1.length x=0 x 0 if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					} cr1[x]!=cr2[j] cr1[x] cr1 x cr2[j] cr2 j {
						dis = "No";
						break;
					} dis = "No" dis "No" break; System.out.println(dis) System.out.println System.out System System.out dis String[] args args
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char[] cr1 = str.toCharArray();
		str = br.readLine();
		char[] cr2 = str.toCharArray();
		String dis = "No";
		int x;
		for(int i=0; i<cr1.length; i++){
			if(dis.equals("Yes")) break;
			if(cr1[i]==cr2[0]){
				dis = "Yes";
				x = i;
				for(int j=1; j<cr2.length; j++){
					x++;
					if(x == cr1.length) x=0;
					if(cr1[x]!=cr2[j]){
						dis = "No";
						break;
					}
				}
			}
		}
		System.out.println(dis);
	}
}