import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char c[] = str.toCharArray(); c str.toCharArray() str.toCharArray str String str2 = sc.next(); str2 sc.next() sc.next sc char c2[] = str2.toCharArray(); c2 str2.toCharArray() str2.toCharArray str2 int n = c.length; n c.length c c.length int offset = 0; offset 0 while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        } offset <= n offset n {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        } boolean ok = true; ok true for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            } {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            } if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                } c[i] != c2[(i+offset) % n] c[i] c i c2[(i+offset) % n] c2 (i+offset) % n (i+offset) i offset n {
                    ok = false;
                    break;
                } ok = false ok false break; if (ok) {
                System.out.println("Yes");
                return;
            } ok {
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; offset++ offset 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) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        String str2 = sc.next();
        char c2[] = str2.toCharArray();
        
        int n = c.length;
        int offset = 0;
        while (offset <= n) {
            boolean ok = true;
            for (int i = 0; i < n; i++) {
                if (c[i] != c2[(i+offset) % n]) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                System.out.println("Yes");
                return;
            }
            offset++;
        }
        
        
        System.out.println("No");
    }
}