public static void main ( String [ ] args ) throws Exception {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  String [ ] l1 = br . readLine ( ) . split ( "" ) ;
  String [ ] l2 = br . readLine ( ) . split ( "" ) ;
  String [ ] l3 = br . readLine ( ) . split ( "" ) ;
  String [ ] l4 = br . readLine ( ) . split ( "" ) ;
  String s1 = "" ;
  if ( ! l1 [ 0 ] . equals ( "X" ) ) s1 += l1 [ 0 ] ;
  if ( ! l1 [ 1 ] . equals ( "X" ) ) s1 += l1 [ 1 ] ;
  if ( ! l2 [ 1 ] . equals ( "X" ) ) s1 += l2 [ 1 ] ;
  if ( ! l2 [ 0 ] . equals ( "X" ) ) s1 += l2 [ 0 ] ;
  String s2 = "" ;
  if ( ! l3 [ 0 ] . equals ( "X" ) ) s2 += l3 [ 0 ] ;
  if ( ! l3 [ 1 ] . equals ( "X" ) ) s2 += l3 [ 1 ] ;
  if ( ! l4 [ 1 ] . equals ( "X" ) ) s2 += l4 [ 1 ] ;
  if ( ! l4 [ 0 ] . equals ( "X" ) ) s2 += l4 [ 0 ] ;
  if ( ( s1 + s1 ) . contains ( s2 ) ) System . out . println ( "YES" ) ;
  else System . out . println ( "NO" ) ;
}

public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] l1 = br . readLine ( ) . split ( " " ) ; String [ ] l2 = br . readLine ( ) . split ( " " ) ; String [ ] l3 = br . readLine ( ) . split ( " " ) ; String [ ] l4 = br . readLine ( ) . split ( " " ) ; String s1 = " " ; if ( ! l1 [ 0 ] . equals ( " X " ) ) s1 += l1 [ 0 ] ; if ( ! l1 [ 1 ] . equals ( " X " ) ) s1 += l1 [ 1 ] ; if ( ! l2 [ 1 ] . equals ( " X " ) ) s1 += l2 [ 1 ] ; if ( ! l2 [ 0 ] . equals ( " X " ) ) s1 += l2 [ 0 ] ; String s2 = " " ; if ( ! l3 [ 0 ] . equals ( " X " ) ) s2 += l3 [ 0 ] ; if ( ! l3 [ 1 ] . equals ( " X " ) ) s2 += l3 [ 1 ] ; if ( ! l4 [ 1 ] . equals ( " X " ) ) s2 += l4 [ 1 ] ; if ( ! l4 [ 0 ] . equals ( " X " ) ) s2 += l4 [ 0 ] ; if ( ( s1 + s1 ) . contains ( s2 ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; }
(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: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (string_literal))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (method_invocation object: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) name: (identifier) arguments: (argument_list (identifier)))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))