public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  } run {
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  } java.util.Scanner sc = new java.util.Scanner(in); sc new java.util.Scanner(in) String s s p; p char[] sch sch pch; pch int i i j j n n sm sm pm; pm s = sc.next() s sc.next() sc.next sc p = sc.next() p sc.next() sc.next sc sm = s.length() sm s.length() s.length s pm = p.length() pm p.length() p.length p sch = new char[sm] sch new char[sm] sm pch = new char[pm] pch new char[pm] pm for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    } i = 0; i = 0 i 0 i < sm i sm i++ i++ i {
      sch[i] = s.charAt(i);
    } {
      sch[i] = s.charAt(i);
    } sch[i] = s.charAt(i) sch[i] sch i s.charAt(i) s.charAt s i for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    } i = 0; i = 0 i 0 i < pm i pm i++ i++ i {
      pch[i] = p.charAt(i);
    } {
      pch[i] = p.charAt(i);
    } pch[i] = p.charAt(i) pch[i] pch i p.charAt(i) p.charAt p i n = 0 n 0 for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    } i = 0; i = 0 i 0 i < sm i sm i++ i++ i {
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    } {
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    } n = 0 n 0 for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      } j = 0; j = 0 j 0 j < pm j pm j++ j++ j {
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      } {
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      } if(sch[(i + j) % sm] == pch[j]){
          n++;
        } sch[(i + j) % sm] == pch[j] sch[(i + j) % sm] sch (i + j) % sm (i + j) i j sm pch[j] pch j {
          n++;
        } n++ n if(n == pm)break; n == pm n pm break; if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    } n != pm n pm {
      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" sc.close() sc.close sc java.io.InputStream in in java.io.PrintStream out out public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  } main {
    (new Main()).run(System.in, System.out);
  } (new Main()).run(System.in, System.out) (new Main()).run (new Main()) System.in System System.in System.out System System.out String[] args args public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String s, p;
    char[] sch, pch;
    int i, j, n, sm, pm;

    s = sc.next();
    p = sc.next();
    sm = s.length();
    pm = p.length();
    sch = new char[sm];
    pch = new char[pm];
    for(i = 0;i < sm;i++){
      sch[i] = s.charAt(i);
    }
    for(i = 0;i < pm;i++){
      pch[i] = p.charAt(i);
    }

    n = 0;
    for(i = 0;i < sm;i++){
      n = 0;
      for(j = 0;j < pm;j++){
        if(sch[(i + j) % sm] == pch[j]){
          n++;
        }
      }
      if(n == pm)break;
    }

    if(n != pm){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}