import java.util.*;

public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    }
/*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    }
/*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    }
/*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    }
}
 import java.util.*; util.* java public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    }
/*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    }
/*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    }
/*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    }
} Main public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    } main {
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str1 = scan.next(); str1 scan.next() scan.next scan String str2 = scan.next(); str2 scan.next() scan.next scan if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        } str1.length() != str2.length() str1.length() str1.length str1 str2.length() str2.length str2 {
            System.out.println("No");
            return;
        } System.out.println("No") System.out.println System.out System System.out "No" return; if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        } str1.length() == 1 str1.length() str1.length str1 1 {
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        } if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            } str1.equals(str2) str1.equals str1 str2 {
                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" return; String[] strArry1 = new String[str1.length()]; strArry1 new String[str1.length()] str1.length() str1.length str1 String[] strArry2 = new String[str2.length()]; strArry2 new String[str2.length()] str2.length() str2.length str2 setArray(strArry1, str1) setArray strArry1 str1 setArray(strArry2, str2) setArray strArry2 str2 String[] wstrArry = new String[str1.length()]; wstrArry new String[str1.length()] str1.length() str1.length str1 for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            } int i = 0; int i = 0; i 0 i < strArry1.length i strArry1.length strArry1 strArry1.length i++ i++ i {
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            } {
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            } cnvArry(wstrArry,strArry1) cnvArry wstrArry strArry1 if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                } comp(wstrArry,strArry2) == 0 comp(wstrArry,strArry2) comp wstrArry strArry2 0 {
                    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" return; String[] args args /*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    } setArray {
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    } for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        } int i = 0; int i = 0; i 0 i < array.length i array.length array array.length i++ i++ i {
            array[i] = String.valueOf(str.charAt(i));
        } {
            array[i] = String.valueOf(str.charAt(i));
        } array[i] = String.valueOf(str.charAt(i)) array[i] array i String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i String[] array array String str str /*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    } comp {
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    } for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        } int i = 0; int i = 0; i 0 i < wstrArry.length i wstrArry.length wstrArry wstrArry.length i++ i++ i {
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        } {
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        } if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            } wstrArry[i].equals(strArry2[i]) wstrArry[i].equals wstrArry[i] wstrArry i strArry2[i] strArry2 i {
                continue;
            } continue; {                
                return 1;
            } return 1; 1 return 0; 0 String[] wstrArry wstrArry String[] strArry2 strArry2 /*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    } cnvArry {
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    } wstrArry[0] = strArry1[strArry1.length - 1] wstrArry[0] wstrArry 0 strArry1[strArry1.length - 1] strArry1 strArry1.length - 1 strArry1.length strArry1 strArry1.length 1 for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        } int j = 0; int j = 0; j 0 j < strArry1.length-1 j strArry1.length-1 strArry1.length strArry1 strArry1.length 1 j++ j++ j {
            wstrArry[j+1] = strArry1[j];
        } {
            wstrArry[j+1] = strArry1[j];
        } wstrArry[j+1] = strArry1[j] wstrArry[j+1] wstrArry j+1 j 1 strArry1[j] strArry1 j for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        } int k = 0; int k = 0; k 0 k < strArry1.length k strArry1.length strArry1 strArry1.length k++ k++ k {
            strArry1[k] = wstrArry[k];
        } {
            strArry1[k] = wstrArry[k];
        } strArry1[k] = wstrArry[k] strArry1[k] strArry1 k wstrArry[k] wstrArry k String[] wstrArry wstrArry String[] strArry1 strArry1 public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    }
/*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    }
/*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    }
/*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    }
} public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    }
/*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    }
/*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    }
/*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    }
} Main
import java.util.*;

public class Main{
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
//
        String str1 = scan.next();
        String str2 = scan.next();
        if(str1.length() != str2.length()){
            System.out.println("No");
            return;
        }
        if(str1.length() == 1){
            if(str1.equals(str2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }            
            return;
        }
//
        String[] strArry1 = new String[str1.length()];
        String[] strArry2 = new String[str2.length()];
//
        setArray(strArry1, str1);
        setArray(strArry2, str2);
//
        String[] wstrArry = new String[str1.length()];
            for (int i = 0; i < strArry1.length; i++){
                cnvArry(wstrArry,strArry1);
                if(comp(wstrArry,strArry2) == 0){
                    System.out.println("Yes");
                    return;
                }
            }            
            System.out.println("No");
            return;
    }
/*
    split strings
*/
    public static void setArray(String[] array, String str){
        for (int i = 0; i < array.length; i++){
            array[i] = String.valueOf(str.charAt(i));
        }
    }
/*
    compare strings
*/
    public static int comp(String[] wstrArry, String[] strArry2){
        for (int i = 0; i < wstrArry.length; i++){
            if(wstrArry[i].equals(strArry2[i])){
                continue;
            }else{                
                return 1;
            }
        }
        return 0;        
    }
/*
    convert
*/
    public static void cnvArry(String[] wstrArry, String[] strArry1){
        wstrArry[0] = strArry1[strArry1.length - 1];
        for (int j = 0; j < strArry1.length-1; j++){
            wstrArry[j+1] = strArry1[j];
        }
//
        for (int k = 0; k < strArry1.length; k++){
            strArry1[k] = wstrArry[k];
        }
    }
}

