import java.util.Scanner;
public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
}
 import java.util.Scanner; Scanner java.util public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
} Main public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  } search {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  } int j = 1; j 1 i = (i + 1) % ring.length() i (i + 1) % ring.length() (i + 1) i 1 ring.length() ring.length ring while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    } j < pattern.length() j pattern.length() pattern.length pattern {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    } if (ring.charAt(i) != pattern.charAt(j))
        return false; ring.charAt(i) != pattern.charAt(j) ring.charAt(i) ring.charAt ring i pattern.charAt(j) pattern.charAt pattern j return false; false i = (i + 1) % ring.length() i (i + 1) % ring.length() (i + 1) i 1 ring.length() ring.length ring j++ j return true; true String ring ring String pattern pattern int i i public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  } patternInRing {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  } int i = 0; i 0 boolean found = false; found false while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    } i < ring.length() i ring.length() ring.length ring {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    } if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      } ring.charAt(i) == pattern.charAt(0) ring.charAt(i) ring.charAt ring i pattern.charAt(0) pattern.charAt pattern 0 {
        if(search(ring, pattern, i))
          return "Yes";
      } if(search(ring, pattern, i))
          return "Yes"; search(ring, pattern, i) search ring pattern i return "Yes"; "Yes" i++ i return "No"; "No" String ring ring String pattern pattern public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  } main {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) String ring = s.next(); ring s.next() s.next s String pattern = s.next(); pattern s.next() s.next s System.out.println(patternInRing(ring, pattern)) System.out.println System.out System System.out patternInRing(ring, pattern) patternInRing ring pattern s.close() s.close s String[] args args public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
} public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
} Main
import java.util.Scanner;
public class Main {

  public static boolean search(String ring, String pattern, int i) {
    int j = 1;
    i = (i + 1) % ring.length();
    while (j < pattern.length()) {
      if (ring.charAt(i) != pattern.charAt(j))
        return false;
      i = (i + 1) % ring.length();
      j++;
    }
    return true;
  }

  public static String patternInRing(String ring, String pattern) {
    int i = 0;
    boolean found = false;
    while (i < ring.length()) {
      if (ring.charAt(i) == pattern.charAt(0)) {
        if(search(ring, pattern, i))
          return "Yes";
      }
      i++;
    }
    return "No";
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String ring = s.next();
    String pattern = s.next();
    System.out.println(patternInRing(ring, pattern));
    s.close();
  }
}

