import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    static int len;
    static boolean ans = false;
    static String line1, line2;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    }
    
    public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    }
} import java.util.HashSet; HashSet java.util import java.util.Set; Set java.util import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util public class Main {
    static int len;
    static boolean ans = false;
    static String line1, line2;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    }
    
    public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    }
} Main static int len; len static boolean ans = false; ans false static String line1 line1 line2; line2 public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) line1 = br.readLine() line1 br.readLine() br.readLine br line2 = br.readLine() line2 br.readLine() br.readLine br len = line1.length() len line1.length() line1.length line1 int x = 0; x 0 int index1 index1 index2; index2 for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        } int i = 0; int i = 0; i 0 i < line1.length() i line1.length() line1.length line1 i++ i++ i {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        } {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        } for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            } int j = 0; int j = 0; j 0 j < line2.length() j line2.length() line2.length line2 j++ j++ j {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            } {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            } if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                } line1.charAt(i) == line2.charAt(j) line1.charAt(i) line1.charAt line1 i line2.charAt(j) line2.charAt line2 j {
                    check(i, j);
                } check(i, j) check i j System.out.println(ans?"Yes":"No") System.out.println System.out System System.out ans?"Yes":"No" ans "Yes" "No" String[] args args public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    } check {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    } int count = 0; count 0 while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        } true {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        } if (i >= len) i -= len; i >= len i len i -= len i len if (j >= len) j -= len; j >= len j len j -= len j len if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break; line1.charAt(i) == line2.charAt(j) line1.charAt(i) line1.charAt line1 i line2.charAt(j) line2.charAt line2 j {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            } i++ i j++ j count++ count if (count == len) {
                    ans = true;
                    return;
                } count == len count len {
                    ans = true;
                    return;
                } ans = true ans true return; continue; break; int i i int j j public class Main {
    static int len;
    static boolean ans = false;
    static String line1, line2;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    }
    
    public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    }
} public class Main {
    static int len;
    static boolean ans = false;
    static String line1, line2;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    }
    
    public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    }
} Main
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    static int len;
    static boolean ans = false;
    static String line1, line2;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        line1 = br.readLine();
        line2 = br.readLine();
        len = line1.length();
        //boolean ans = false;
        //boolean next = false;
        int x = 0;
        int index1, index2;
        for (int i = 0; i < line1.length(); i++) {
            for (int j = 0; j < line2.length(); j++) {
                if (line1.charAt(i) == line2.charAt(j)) {
                    check(i, j);
                }
                
            }
        }
        System.out.println(ans?"Yes":"No");
    }
    
    public static void check(int i, int j) {
        int count = 0;
        while (true) {
            if (i >= len) i -= len;
            if (j >= len) j -= len;
            if (line1.charAt(i) == line2.charAt(j)) {
                i++;
                j++;
                count++;
                if (count == len) {
                    ans = true;
                    return;
                }
                continue;
            }
            else break;
        }
    }
}
