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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    } main {
        
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            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 char words[] = new char[s1.length()]; words new char[s1.length()] s1.length() s1.length s1 for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        } int i = 0; int i = 0; i 0 i < s1.length() i s1.length() s1.length s1 i++ i++ i {
            words[i] = s1.charAt(i);
        } {
            words[i] = s1.charAt(i);
        } words[i] = s1.charAt(i) words[i] words i s1.charAt(i) s1.charAt s1 i boolean match = false; match false for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        } int i = 0; int i = 0; i 0 i < s1.length() i s1.length() s1.length s1 i++ i++ i {
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        } {
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        } if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            } s2.equals(String.valueOf(words)) s2.equals s2 String.valueOf(words) String.valueOf String words {
                match = true;
                break;
            } match = true match true break; {
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            } char tmp = words[s1.length() - 1]; tmp words[s1.length() - 1] words s1.length() - 1 s1.length() s1.length s1 1 for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                } int j = s1.length() - 1; int j = s1.length() - 1; j s1.length() - 1 s1.length() s1.length s1 1 j > 0 j 0 j-- j-- j {
                    words[j] = words[j - 1];
                } {
                    words[j] = words[j - 1];
                } words[j] = words[j - 1] words[j] words j words[j - 1] words j - 1 j 1 words[0] = tmp words[0] words 0 tmp if(match){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        } match {
            System.out.println("Yes");
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } 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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            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();
        
        char words[] = new char[s1.length()];
        for(int i = 0; i < s1.length(); i++){
            words[i] = s1.charAt(i);
        }
        
        boolean match = false;
        for(int i = 0; i < s1.length(); i++){
            if(s2.equals(String.valueOf(words))){
                match = true;
                break;
            }else{
                char tmp = words[s1.length() - 1];
                for(int j = s1.length() - 1; j > 0; j--){
                    words[j] = words[j - 1];
                }
                words[0] = tmp;
            }
        }
        
        if(match){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}
