import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    } main {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s1 = sc.next(); s1 sc.next() sc.next sc String s2 = sc.next(); s2 sc.next() sc.next sc StringBuilder sb = new StringBuilder(); sb new StringBuilder() boolean same = false; same false for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        } int i = 0; int i = 0; i 0 i < s1.length() i s1.length() s1.length s1 i++ i++ i {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        } {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        } sb.setLength(0) sb.setLength sb 0 sb.append(s1.substring(i)).append(s1.substring(0, i)) sb.append(s1.substring(i)).append sb.append(s1.substring(i)) sb.append sb s1.substring(i) s1.substring s1 i s1.substring(0, i) s1.substring s1 0 i if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            } sb.toString().compareTo(s2) == 0 sb.toString().compareTo(s2) sb.toString().compareTo sb.toString() sb.toString sb s2 0 {
                same = true;
                break;
            } same = true same true break; if (same)
            System.out.println("Yes");
        else
            System.out.println("No"); same System.out.println("Yes") System.out.println System.out System System.out "Yes" 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 s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            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 s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        StringBuilder sb = new StringBuilder();
        boolean same = false;
        for (int i = 0; i < s1.length(); i++) {
            sb.setLength(0);
            sb.append(s1.substring(i)).append(s1.substring(0, i));
            if (sb.toString().compareTo(s2) == 0) {
                same = true;
                break;
            }
        }
        if (same)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}
