import java.util.Scanner;

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

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    String[] myArgs = new String[2];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.next();
    myArgs[1] = sc.next();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
} Main public static void main(String[] args) {
    String[] myArgs = new String[2];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.next();
    myArgs[1] = sc.next();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  } main {
    String[] myArgs = new String[2];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.next();
    myArgs[1] = sc.next();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  } String[] myArgs = new String[2]; myArgs new String[2] 2 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) myArgs[0] = sc.next() myArgs[0] myArgs 0 sc.next() sc.next sc myArgs[1] = sc.next() myArgs[1] myArgs 1 sc.next() sc.next sc Main logic = new Main(); logic new Main() String output = logic.exec(myArgs); output logic.exec(myArgs) logic.exec logic myArgs System.out.print(output) System.out.print System.out System System.out output String[] args args private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  } exec {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  } final char[] compareTo = myArgs[0].toCharArray(); compareTo myArgs[0].toCharArray() myArgs[0].toCharArray myArgs[0] myArgs 0 char[] compareBy = myArgs[1].toCharArray(); compareBy myArgs[1].toCharArray() myArgs[1].toCharArray myArgs[1] myArgs 1 if (compareBy.length != compareTo.length) {
      return "No";
    } compareBy.length != compareTo.length compareBy.length compareBy compareBy.length compareTo.length compareTo compareTo.length {
      return "No";
    } return "No"; "No" for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    } int i = 0; int i = 0; i 0 i < compareBy.length i compareBy.length compareBy compareBy.length i++ i++ i {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    } {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    } boolean same = true; same true for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      } int j = 0; int j = 0; j 0 j < compareTo.length j compareTo.length compareTo compareTo.length j++ j++ j {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      } {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      } int index = i + j; index i + j i j if (index >= compareTo.length) {
          index -= compareTo.length;
        } index >= compareTo.length index compareTo.length compareTo compareTo.length {
          index -= compareTo.length;
        } index -= compareTo.length index compareTo.length compareTo compareTo.length if (compareBy[index] != compareTo[j]) {
          same = false;
        } compareBy[index] != compareTo[j] compareBy[index] compareBy index compareTo[j] compareTo j {
          same = false;
        } same = false same false if (same) {
        return "Yes";
      } same {
        return "Yes";
      } return "Yes"; "Yes" return "No"; "No" String[] myArgs myArgs public class Main {
  public static void main(String[] args) {
    String[] myArgs = new String[2];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.next();
    myArgs[1] = sc.next();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
} public class Main {
  public static void main(String[] args) {
    String[] myArgs = new String[2];
    Scanner sc = new Scanner(System.in);
    myArgs[0] = sc.next();
    myArgs[1] = sc.next();

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
} Main
import java.util.Scanner;

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

    Main logic = new Main();
    String output = logic.exec(myArgs);
    System.out.print(output);
  }
  private String exec(String[] myArgs) {
    final char[] compareTo = myArgs[0].toCharArray();
    char[] compareBy = myArgs[1].toCharArray();
    if (compareBy.length != compareTo.length) {
      return "No";
    }
    for (int i = 0;i < compareBy.length;i++) {
      boolean same = true;
      for (int j = 0;j < compareTo.length;j++) {
        int index = i + j;
        if (index >= compareTo.length) {
          index -= compareTo.length;
        }
        if (compareBy[index] != compareTo[j]) {
          same = false;
        }
      }
      if (same) {
        return "Yes";
      }
    }

    return "No";
  }
}
