public static void main ( String args [ ] ) {
  FastScanner in = new FastScanner ( ) ;
  int t = in . nextInt ( ) ;
  L : while ( -- t >= 0 ) {
    char s [ ] = ( in . next ( ) + "_" ) . toCharArray ( ) ;
    char p [ ] = ( in . next ( ) + "_" ) . toCharArray ( ) ;
    int n1 = s . length ;
    int n2 = p . length ;
    int i = 0 , j = 0 ;
    boolean chk = false ;
    while ( i < n1 && j < n2 ) {
      if ( s [ i ] == p [ j ] ) {
        i ++ ;
        int ctr1 = 1 ;
        while ( i < n1 && s [ i ] == s [ i - 1 ] ) {
          i ++ ;
          ctr1 ++ ;
        }
        j ++ ;
        int ctr2 = 1 ;
        while ( j < n2 && p [ j ] == p [ j - 1 ] ) {
          j ++ ;
          ctr2 ++ ;
        }
        if ( ctr1 > ctr2 ) {
          chk = true ;
          break ;
        }
      }
      else {
        chk = true ;
        break ;
      }
    }
    if ( ! chk ) System . out . println ( "YES" ) ;
    else System . out . println ( "NO" ) ;
  }
}

public static void main ( String args [ ] ) { FastScanner in = new FastScanner ( ) ; int t = in . nextInt ( ) ; L : while ( -- t >= 0 ) { char s [ ] = ( in . next ( ) + " _ " ) . toCharArray ( ) ; char p [ ] = ( in . next ( ) + " _ " ) . toCharArray ( ) ; int n1 = s . length ; int n2 = p . length ; int i = 0 , j = 0 ; boolean chk = false ; while ( i < n1 && j < n2 ) { if ( s [ i ] == p [ j ] ) { i ++ ; int ctr1 = 1 ; while ( i < n1 && s [ i ] == s [ i - 1 ] ) { i ++ ; ctr1 ++ ; } j ++ ; int ctr2 = 1 ; while ( j < n2 && p [ j ] == p [ j - 1 ] ) { j ++ ; ctr2 ++ ; } if ( ctr1 > ctr2 ) { chk = true ; break ; } } else { chk = true ; break ; } } if ( ! chk ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_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)))) (labeled_statement (identifier) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (method_invocation object: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (string_literal))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (method_invocation object: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (string_literal))) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (update_expression (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier))))) (expression_statement (update_expression (identifier))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal)))))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (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))))))))))