import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.regex.Matcher; Matcher java.util.regex import java.util.regex.Pattern; Pattern java.util.regex public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	}
} Main public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	} main {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br String p = br.readLine(); p br.readLine() br.readLine br String targetStr = s + s; targetStr s + s s s StringBuilder sb = new StringBuilder(); sb new StringBuilder() Pattern ptn = Pattern.compile(p); ptn Pattern.compile(p) Pattern.compile Pattern p Matcher matcher = ptn.matcher(targetStr); matcher ptn.matcher(targetStr) ptn.matcher ptn targetStr if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        } matcher.find() matcher.find matcher {
            sb.append("Yes");
        } sb.append("Yes") sb.append sb "Yes" {
            sb.append("No");
        } sb.append("No") sb.append sb "No" System.out.println(sb.toString()) System.out.println System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	}
} public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String s = br.readLine();
	    String p = br.readLine();

	    String targetStr = s + s;
	    StringBuilder sb = new StringBuilder();
        Pattern ptn = Pattern.compile(p);
        Matcher matcher = ptn.matcher(targetStr);
        if(matcher.find()){
            sb.append("Yes");
        }else{
            sb.append("No");
        }
        System.out.println(sb.toString());
	}
}