import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      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.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } main {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc String t = sc.next(); t sc.next() sc.next sc char[] c1 = s.toCharArray(); c1 s.toCharArray() s.toCharArray s char[] c2 = t.toCharArray(); c2 t.toCharArray() t.toCharArray t int l = c1.length; l c1.length c1 c1.length boolean flag = false; flag false for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    } int i=0; int i=0; i 0 i<=l-1 i l-1 l 1 i++ i++ i {
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    } {
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    } int count = 0; count 0 for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      } int j=0; int j=0; j 0 j<l j l j++ j++ j {
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      } {
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      } if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        } c1[(j+i)%l] == c2[j] c1[(j+i)%l] c1 (j+i)%l (j+i) j i l c2[j] c2 j {
          count += 1;
        } count += 1 count 1 {
          break;
        } break; if(count == l){
        flag = true;
        break;
      } count == l count l {
        flag = true;
        break;
      } flag = true flag true break; if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    } flag {
      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.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      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.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();

    char[] c1 = s.toCharArray();
    char[] c2 = t.toCharArray();

    int l = c1.length;
    boolean flag = false;

    for(int i=0; i<=l-1; i++ ){
      int count = 0;
      for(int j=0; j<l; j++){
        if(c1[(j+i)%l] == c2[j]){
          count += 1;
        }else{
          break;
        }
      }
      if(count == l){
        flag = true;
        break;
      }
    }

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