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

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder builder = new StringBuilder();

		String str1 = br.readLine();

		String str2 = br.readLine();


		if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		}


	}


 private static int kmpSearch(String text, String pattern){
  int textIndex = 1;
  int patternIndex = 0;
  int[] cacheTable = new int[pattern.length() + 1];
  cacheTable[0] = cacheTable[1] = 0;

  while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  }

  int i = 0;
  int n = 0;
  while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  }

  return -1;
 }

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

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder builder = new StringBuilder();

		String str1 = br.readLine();

		String str2 = br.readLine();


		if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		}


	}


 private static int kmpSearch(String text, String pattern){
  int textIndex = 1;
  int patternIndex = 0;
  int[] cacheTable = new int[pattern.length() + 1];
  cacheTable[0] = cacheTable[1] = 0;

  while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  }

  int i = 0;
  int n = 0;
  while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  }

  return -1;
 }

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder builder = new StringBuilder();

		String str1 = br.readLine();

		String str2 = br.readLine();


		if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		}


	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder builder = new StringBuilder();

		String str1 = br.readLine();

		String str2 = br.readLine();


		if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		}


	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder builder = new StringBuilder(); builder new StringBuilder() String str1 = br.readLine(); str1 br.readLine() br.readLine br String str2 = br.readLine(); str2 br.readLine() br.readLine br if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		} kmpSearch(str1+str1, str2)== -1 kmpSearch(str1+str1, str2) kmpSearch str1+str1 str1 str1 str2 -1 1 {
			System.out.println("No");

		} System.out.println("No") System.out.println System.out System System.out "No" {
			System.out.println("Yes");
		} System.out.println("Yes") System.out.println System.out System System.out "Yes" String[] args args private static int kmpSearch(String text, String pattern){
  int textIndex = 1;
  int patternIndex = 0;
  int[] cacheTable = new int[pattern.length() + 1];
  cacheTable[0] = cacheTable[1] = 0;

  while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  }

  int i = 0;
  int n = 0;
  while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  }

  return -1;
 } kmpSearch {
  int textIndex = 1;
  int patternIndex = 0;
  int[] cacheTable = new int[pattern.length() + 1];
  cacheTable[0] = cacheTable[1] = 0;

  while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  }

  int i = 0;
  int n = 0;
  while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  }

  return -1;
 } int textIndex = 1; textIndex 1 int patternIndex = 0; patternIndex 0 int[] cacheTable = new int[pattern.length() + 1]; cacheTable new int[pattern.length() + 1] pattern.length() + 1 pattern.length() pattern.length pattern 1 cacheTable[0] = cacheTable[1] = 0 cacheTable[0] cacheTable 0 cacheTable[1] = 0 cacheTable[1] cacheTable 1 0 while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  } pattern.length() > textIndex pattern.length() pattern.length pattern textIndex {
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  } if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   } pattern.charAt(textIndex) == pattern.charAt(patternIndex) pattern.charAt(textIndex) pattern.charAt pattern textIndex pattern.charAt(patternIndex) pattern.charAt pattern patternIndex {

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } textIndex++ textIndex patternIndex++ patternIndex cacheTable[textIndex] = patternIndex cacheTable[textIndex] cacheTable textIndex patternIndex if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   } patternIndex == 0 patternIndex 0 {

    textIndex++;
    cacheTable[textIndex] = 0;
   } textIndex++ textIndex cacheTable[textIndex] = 0 cacheTable[textIndex] cacheTable textIndex 0 {

    patternIndex = cacheTable[patternIndex];
   } patternIndex = cacheTable[patternIndex] patternIndex cacheTable[patternIndex] cacheTable patternIndex int i = 0; i 0 int n = 0; n 0 while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  } n < text.length() n text.length() text.length text {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  } if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   } text.charAt(n) == pattern.charAt(i) text.charAt(n) text.charAt text n pattern.charAt(i) pattern.charAt pattern i {
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } ++n n ++i i if(pattern.length() == i){

     return n - pattern.length();
    } pattern.length() == i pattern.length() pattern.length pattern i {

     return n - pattern.length();
    } return n - pattern.length(); n - pattern.length() n pattern.length() pattern.length pattern if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   } i == 0 i 0 {

    ++n;
   } ++n n {

    i = cacheTable[i];
   } i = cacheTable[i] i cacheTable[i] cacheTable i return -1; -1 1 String text text String pattern pattern
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder builder = new StringBuilder();

		String str1 = br.readLine();

		String str2 = br.readLine();


		if(kmpSearch(str1+str1, str2)== -1){
			System.out.println("No");

		}else {
			System.out.println("Yes");
		}


	}


 private static int kmpSearch(String text, String pattern){
  int textIndex = 1;
  int patternIndex = 0;
  int[] cacheTable = new int[pattern.length() + 1];
  cacheTable[0] = cacheTable[1] = 0;

  while(pattern.length() > textIndex ){
   if(pattern.charAt(textIndex) == pattern.charAt(patternIndex)){

    textIndex++;
    patternIndex++;
    cacheTable[textIndex] = patternIndex;
   } else if (patternIndex == 0){

    textIndex++;
    cacheTable[textIndex] = 0;
   } else {

    patternIndex = cacheTable[patternIndex];
   }
  }

  int i = 0;
  int n = 0;
  while(n < text.length()) {

   if(text.charAt(n) == pattern.charAt(i)){
    ++n;
    ++i;
    if(pattern.length() == i){

     return n - pattern.length();
    }
   } else if ( i == 0){

    ++n;
   } else {

    i = cacheTable[i];
   }
  }

  return -1;
 }

}