public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  String a = sc . nextLine ( ) ;
  String [ ] b = a . split ( " " , 0 ) ;
  System . out . println ( ( b [ 0 ] . substring ( b [ 0 ] . length ( ) - 1 , b [ 0 ] . length ( ) ) . equals ( b [ 1 ] . substring ( 0 , 1 ) ) && b [ 1 ] . substring ( b [ 1 ] . length ( ) - 1 , b [ 1 ] . length ( ) ) . equals ( b [ 2 ] . substring ( 0 , 1 ) ) ) ? "YES" : "NO" ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . nextLine ( ) ; String [ ] b = a . split ( " ▁ " , 0 ) ; System . out . println ( ( b [ 0 ] . substring ( b [ 0 ] . length ( ) - 1 , b [ 0 ] . length ( ) ) . equals ( b [ 1 ] . substring ( 0 , 1 ) ) && b [ 1 ] . substring ( b [ 1 ] . length ( ) - 1 , b [ 1 ] . length ( ) ) . equals ( b [ 2 ] . substring ( 0 , 1 ) ) ) ? " YES " : " NO " ) ; }
(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 (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: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (decimal_integer_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (ternary_expression condition: (parenthesized_expression (binary_expression left: (method_invocation object: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list)))) name: (identifier) arguments: (argument_list (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))) right: (method_invocation object: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list)))) name: (identifier) arguments: (argument_list (method_invocation object: (array_access array: (identifier) index: (decimal_integer_literal)) name: (identifier) arguments: (argument_list (decimal_integer_literal) (decimal_integer_literal))))))) consequence: (string_literal) alternative: (string_literal)))))))