import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


} Main public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    } main {


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String word = br.readLine(); word br.readLine() br.readLine br String key = br.readLine(); key br.readLine() br.readLine br word = word + word.substring(0, key.length() - 1) word word + word.substring(0, key.length() - 1) word word.substring(0, key.length() - 1) word.substring word 0 key.length() - 1 key.length() key.length key 1 if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        } bmStringSearch(word,key) bmStringSearch word key {
        	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 private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    } bmStringSearch {
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    } int[] table = new int[256]; table new int[256] 256 for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         } int i=0; int i=0; i 0 i<table.length i table.length table table.length i++ i++ i {
         	table[i] = key.length();
         } {
         	table[i] = key.length();
         } table[i] = key.length() table[i] table i key.length() key.length key for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         } int i=0; int i=0; i 0 i<key.length() i key.length() key.length key i++ i++ i {
         	table[key.charAt(i)] = key.length() - i - 1;
         } {
         	table[key.charAt(i)] = key.length() - i - 1;
         } table[key.charAt(i)] = key.length() - i - 1 table[key.charAt(i)] table key.charAt(i) key.charAt key i key.length() - i - 1 key.length() - i - 1 key.length() key.length key i 1 int wordIndex = key.length() - 1; wordIndex key.length() - 1 key.length() key.length key 1 while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         } wordIndex < word.length() wordIndex word.length() word.length word {
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         } int keyIndex = key.length() -1; keyIndex key.length() -1 key.length() key.length key 1 while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	} word.charAt(wordIndex) == key.charAt(keyIndex) word.charAt(wordIndex) word.charAt word wordIndex key.charAt(keyIndex) key.charAt key keyIndex {
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	} if(keyIndex == 0){
         			return true;
         		} keyIndex == 0 keyIndex 0 {
         			return true;
         		} return true; true wordIndex-- wordIndex keyIndex-- keyIndex if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	} table[word.charAt(wordIndex)] > key.length()-keyIndex table[word.charAt(wordIndex)] table word.charAt(wordIndex) word.charAt word wordIndex key.length()-keyIndex key.length() key.length key keyIndex {
         		wordIndex += table[word.charAt(wordIndex)];
         	} wordIndex += table[word.charAt(wordIndex)] wordIndex table[word.charAt(wordIndex)] table word.charAt(wordIndex) word.charAt word wordIndex {
         		wordIndex += key.length() - keyIndex;
         	} wordIndex += key.length() - keyIndex wordIndex key.length() - keyIndex key.length() key.length key keyIndex return false; false String word word String key key public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


} public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        String key = br.readLine();
        word = word + word.substring(0, key.length() - 1);

        if(bmStringSearch(word,key)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }

    }

    private static boolean bmStringSearch(String word, String key){
    	 int[] table = new int[256];

         for(int i=0;i<table.length;i++){
         	table[i] = key.length();
         }
         for(int i=0;i<key.length();i++){
         	table[key.charAt(i)] = key.length() - i - 1;
         }

         int wordIndex = key.length() - 1;
         while(wordIndex < word.length()){
         	int keyIndex = key.length() -1;

         	while(word.charAt(wordIndex) == key.charAt(keyIndex)){
         		if(keyIndex == 0){
         			return true;
         		}
         		wordIndex--;
         		keyIndex--;
         	}

         	if(table[word.charAt(wordIndex)] > key.length()-keyIndex){
         		wordIndex += table[word.charAt(wordIndex)];
         	}else{
         		wordIndex += key.length() - keyIndex;
         	}
         }

         return false;
    }


}