import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private boolean check(char[] S, char[] T, int si, int sj) {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    private boolean check(char[] S, char[] T, int si, int sj) {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    }

} Solver private boolean check(char[] S, char[] T, int si, int sj) {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    } check {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    } int N = S.length; N S.length S S.length for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        } {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        } if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            } S[(si + i) % N] !=  T[(sj + i) % N] S[(si + i) % N] S (si + i) % N (si + i) si i N T[(sj + i) % N] T (sj + i) % N (sj + i) sj i N {
                return false;
            } return false; false return true; true char[] S S char[] T T int si si int sj sj public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] S = sc.next().toCharArray(); S sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc char[] T = sc.next().toCharArray(); T sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc boolean rotatable = false; rotatable false for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        } int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        } {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        } char ch = S[i]; ch S[i] S i for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            } int j = 0; int j = 0; j 0 j < T.length j T.length T T.length j++ j++ j {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            } {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            } if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                } ch == T[j] ch T[j] T j {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                } if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    } check(S, T, i, j) check S T i j {
                        System.out.println("Yes");
                        return;
                    } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return;
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private boolean check(char[] S, char[] T, int si, int sj) {
        int N = S.length;
        for (int i = 0; i < N; i++) {
            if (S[(si + i) % N] !=  T[(sj + i) % N]) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        boolean rotatable = false;
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            // find ch
            for (int j = 0; j < T.length; j++) {
                if (ch == T[j]) {
                    // start check
                    if (check(S, T, i, j)) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        
        System.out.println("No");

        return;
    }

}