import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        String s1 = scan.next();
        String s2 = scan.next();
        if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        }
        int i , j;
        for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        String s1 = scan.next();
        String s2 = scan.next();
        if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        }
        int i , j;
        for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        String s1 = scan.next();
        String s2 = scan.next();
        if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        }
        int i , j;
        for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    } main {
        Scanner scan = new Scanner(System.in);

        String s1 = scan.next();
        String s2 = scan.next();
        if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        }
        int i , j;
        for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String s1 = scan.next(); s1 scan.next() scan.next scan String s2 = scan.next(); s2 scan.next() scan.next scan if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        } s1.length() != s2.length() s1.length() s1.length s1 s2.length() s2.length s2 {
            System.out.println("No");
            return;
        } System.out.println("No") System.out.println System.out System System.out "No" return; int i i j; j for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        } i = 0; i = 0 i 0 i < s1.length() i s1.length() s1.length s1 i++ i++ i {
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        } {
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        } for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            } j = 0; j = 0 j 0 j < s1.length() j s1.length() s1.length s1 j++ j++ j {
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            } {
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            } if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue; s1.charAt((i+j)%s1.length())==s2.charAt(j) s1.charAt((i+j)%s1.length()) s1.charAt s1 (i+j)%s1.length() (i+j) i j s1.length() s1.length s1 s2.charAt(j) s2.charAt s2 j continue; break; if(j == s1.length()){
                System.out.println("Yes");
                return;
            } j == s1.length() j s1.length() s1.length s1 {
                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" String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        String s1 = scan.next();
        String s2 = scan.next();
        if(s1.length() != s2.length()){
            System.out.println("No");
            return;
        }
        int i , j;
        for(i = 0; i < s1.length(); i++){
            for(j = 0; j < s1.length(); j++){
                if(s1.charAt((i+j)%s1.length())==s2.charAt(j))
                    continue;
                break;
            }
            if(j == s1.length()){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}
