import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
} import java.util.*; util.* java import java.io.*; io.* java import java.math.*; math.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    } main {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    } 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 if(s.length != t.length) {
            System.out.println("No");
            return;
        } s.length != t.length s.length s s.length t.length t t.length {
            System.out.println("No");
            return;
        } System.out.println("No") System.out.println System.out System System.out "No" return; int len = s.length; len s.length s s.length ArrayList<Character> sl = new ArrayList<Character>(); sl new ArrayList<Character>() for(char c : s){
            sl.add(c);
        } char c s {
            sl.add(c);
        } {
            sl.add(c);
        } sl.add(c) sl.add sl c for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        } int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        } {
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        } boolean bool = true; bool true for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            } int j = 0; int j = 0; j 0 j < len j len j++ j++ j {
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            } {
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            } if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                } sl.get(j) != t[j] sl.get(j) sl.get sl j t[j] t j {
                    bool = false;
                    break;
                } bool = false bool false break; if(bool){
                System.out.println("Yes");
                return;
            } bool {
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; Collections.rotate(sl,1) Collections.rotate Collections sl 1 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 {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
} Main
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        if(s.length != t.length) {
            System.out.println("No");
            return;
        }
        int len = s.length;
        ArrayList<Character> sl = new ArrayList<Character>();
        for(char c : s){
            sl.add(c);
        }
        for(int i = 0; i < len; i++){
            boolean bool = true;
            for(int j = 0; j < len; j++){
                if(sl.get(j) != t[j]){
                    bool = false;
                    break;
                }
            }
            if(bool){
                System.out.println("Yes");
                return;
            }
            Collections.rotate(sl,1);
        }
        System.out.println("No");
    }
}