import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

} import java.io.*; io.* java import java.util.*; util.* java public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

} Main private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    } solve {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    } String s = in.next(); s in.next() in.next in String t = in.next(); t in.next() in.next in char[] arrS = s.toCharArray(); arrS s.toCharArray() s.toCharArray s char[] arrT = t.toCharArray(); arrT t.toCharArray() t.toCharArray t Arrays.sort(arrS) Arrays.sort Arrays arrS Arrays.sort(arrT) Arrays.sort Arrays arrT if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        } !Arrays.equals(arrS, arrT) Arrays.equals(arrS, arrT) Arrays.equals Arrays arrS arrT {
            out.println("No");
            return;
        } out.println("No") out.println out "No" return; arrS = s.toCharArray() arrS s.toCharArray() s.toCharArray s char[] res = new char[arrS.length]; res new char[arrS.length] arrS.length arrS arrS.length arrT = t.toCharArray() arrT t.toCharArray() t.toCharArray t for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        } int i = 0; int i = 0; i 0 i < arrS.length i arrS.length arrS arrS.length i++ i++ i {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        } {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        } for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            } int j = 0; int j = 0; j 0 j < arrS.length j arrS.length arrS arrS.length j++ j++ j {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            } {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            } res[(j + 1) % arrS.length] = arrS[j] res[(j + 1) % arrS.length] res (j + 1) % arrS.length (j + 1) j 1 arrS.length arrS arrS.length arrS[j] arrS j if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                } Arrays.equals(arrS, arrT) Arrays.equals Arrays arrS arrT {
                    out.println("Yes");
                    return;
                } out.println("Yes") out.println out "Yes" return; arrS = res.clone() arrS res.clone() res.clone res out.println("No") out.println out "No" InputReader in in PrintWriter out out public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    } run {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    } try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        } {
            solve(in, out);
        } InputReader in = new InputReader(System.in) InputReader in = new InputReader(System.in) new InputReader(System.in) PrintWriter out = new PrintWriter(System.out) PrintWriter out = new PrintWriter(System.out) new PrintWriter(System.out) solve(in, out) solve in out static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    } InputReader private BufferedReader reader; reader private StringTokenizer tokenizer; tokenizer public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } InputReader {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(stream), 32768) reader new BufferedReader(new InputStreamReader(stream), 32768) tokenizer = null tokenizer null InputStream stream stream public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next @Override
        public void close() {

        } close {

        } AutoCloseable public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

} public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

} Main
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}
