public static void main ( String [ ] args ) {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  OutputStream output = System . out ;
  PrintWriter pr = new PrintWriter ( output ) ;
  try {
    String line1 = br . readLine ( ) ;
    StringBuilder sb = new StringBuilder ( br . readLine ( ) ) ;
    line1 += sb . reverse ( ) ;
    line1 = line1 . replace ( "X" , "" ) ;
    String line2 = br . readLine ( ) ;
    sb = new StringBuilder ( br . readLine ( ) ) ;
    line2 += sb . reverse ( ) ;
    line2 = line2 . replace ( "X" , "" ) ;
    pr . println ( ( line1 + line1 ) . contains ( line2 ) ? "YES" : "NO" ) ;
    pr . close ( ) ;
  }
  catch ( IOException e ) {
    e . printStackTrace ( ) ;
  }
}

public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; OutputStream output = System . out ; PrintWriter pr = new PrintWriter ( output ) ; try { String line1 = br . readLine ( ) ; StringBuilder sb = new StringBuilder ( br . readLine ( ) ) ; line1 += sb . reverse ( ) ; line1 = line1 . replace ( " X " , " " ) ; String line2 = br . readLine ( ) ; sb = new StringBuilder ( br . readLine ( ) ) ; line2 += sb . reverse ( ) ; line2 = line2 . replace ( " X " , " " ) ; pr . println ( ( line1 + line1 ) . contains ( line2 ) ? " YES " : " NO " ) ; pr . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (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: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (try_statement body: (block (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: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (string_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (ternary_expression condition: (method_invocation object: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) name: (identifier) arguments: (argument_list (identifier))) consequence: (string_literal) alternative: (string_literal))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))))