public static void main ( String [ ] args ) throws IOException {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  String A = br . readLine ( ) ;
  String B = br . readLine ( ) ;
  int lengths = A . length ( ) ;
  boolean Bb [ ] = new boolean [ lengths ] ;
  for ( int i = 0 ;
  i < lengths ;
  i ++ ) {
    Bb [ i ] = false ;
  }
  int k = 0 ;
  for ( int i = 0 ;
  i < lengths ;
  i ++ ) {
    if ( i == 0 ) {
      for ( int j = 0 ;
      ;
      j ++ ) {
        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 ;
      if ( ! A . substring ( i , i + 1 ) . equals ( B . substring ( l , l + 1 ) ) ) {
        i = - 1 ;
      }
    }
  }
  System . out . println ( "Yes" ) ;
}

public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String A = br . readLine ( ) ; String B = br . readLine ( ) ; int lengths = A . length ( ) ; boolean Bb [ ] = new boolean [ lengths ] ; for ( int i = 0 ; i < lengths ; i ++ ) { Bb [ i ] = false ; } int k = 0 ; for ( int i = 0 ; i < lengths ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; ; j ++ ) { 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 ; if ( ! A . substring ( i , i + 1 ) . equals ( B . substring ( l , l + 1 ) ) ) { i = - 1 ; } } } System . out . println ( " Yes " ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (false))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (unary_expression operand: (array_access array: (identifier) index: (identifier))) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (true))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (break_statement)))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) consequence: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) alternative: (binary_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (decimal_integer_literal)))))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))