import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

} Main public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	} main {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String A = br.readLine(); A br.readLine() br.readLine br String B = br.readLine(); B br.readLine() br.readLine br int lengths = A.length(); lengths A.length() A.length A boolean Bb[] = new boolean[lengths]; Bb new boolean[lengths] lengths for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		} int i = 0; int i = 0; i 0 i < lengths i lengths i++ i++ i {
			//Ab[i] = false;
			Bb[i] = false;
		} {
			//Ab[i] = false;
			Bb[i] = false;
		} Bb[i] = false Bb[i] Bb i false int k = 0; k 0 for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		} int i = 0; int i = 0; i 0 i < lengths i lengths i++ i++ i {
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		} {
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		} if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			} i == 0 i 0 {
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			} for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				} int j = 0; int j = 0; j 0 j++ j++ j {
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				} {
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				} if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					} j == lengths j lengths {
						System.out.println("No");
						System.exit(0);
					} System.out.println("No") System.out.println System.out System System.out "No" System.exit(0) System.exit System 0 if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					} !Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)) !Bb[j] Bb[j] Bb j A.substring(i, i+1).equals(B.substring(j, j+1)) A.substring(i, i+1).equals A.substring(i, i+1) A.substring A i i+1 i 1 B.substring(j, j+1) B.substring B j j+1 j 1 {
						Bb[j] = true;
						k = j;
						break;
					} Bb[j] = true Bb[j] Bb j true k = j k j break; {
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			} int l = k+i >= lengths ? k+i-lengths : k+i; l k+i >= lengths ? k+i-lengths : k+i k+i >= lengths k+i k i lengths k+i-lengths k+i k i lengths k+i k i if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				} !A.substring(i, i+1).equals(B.substring(l, l+1)) A.substring(i, i+1).equals(B.substring(l, l+1)) A.substring(i, i+1).equals A.substring(i, i+1) A.substring A i i+1 i 1 B.substring(l, l+1) B.substring B l l+1 l 1 {
					i = -1;
				} i = -1 i -1 1 System.out.println("Yes") System.out.println System.out System System.out "Yes" String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

}
