public static void printSmallest ( String s , Query [ ] q ) {
  int N = s . length ( ) ;
  int [ ] [ ] H = new int [ N + 1 ] [ 26 ] ;
  for ( int i = 1 ;
  i <= N ;
  i ++ ) {
    ++ H [ i ] [ s . charAt ( i - 1 ) - 'a' ] ;
    for ( int j = 0 ;
    j < 26 ;
    j ++ ) {
      H [ i ] [ j ] += H [ i - 1 ] [ j ] ;
    }
  }
  int m = q . length ;
  for ( int j = 0 ;
  j < m ;
  j ++ ) {
    int l = q [ j ] . l , r = q [ j ] . r , n = q [ j ] . n ;
    int sum = 0 ;
    for ( int i = 0 ;
    i < 26 ;
    i ++ ) {
      sum += H [ r ] [ i ] - H [ l - 1 ] [ i ] ;
      if ( sum >= n ) {
        System . out . println ( ( char ) ( 'a' + i ) ) ;
        break ;
      }
    }
  }
}

public static void printSmallest ( String s , Query [ ] q ) { int N = s . length ( ) ; int [ ] [ ] H = new int [ N + 1 ] [ 26 ] ; for ( int i = 1 ; i <= N ; i ++ ) { ++ H [ i ] [ s . charAt ( i - 1 ) - ' a ' ] ; for ( int j = 0 ; j < 26 ; j ++ ) { H [ i ] [ j ] += H [ i - 1 ] [ j ] ; } } int m = q . length ; for ( int j = 0 ; j < m ; j ++ ) { int l = q [ j ] . l , r = q [ j ] . r , n = q [ j ] . n ; int sum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { sum += H [ r ] [ i ] - H [ l - 1 ] [ i ] ; if ( sum >= n ) { System . out . println ( ( char ) ( ' a ' + i ) ) ; break ; } } } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal))) dimensions: (dimensions_expr (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 (expression_statement (update_expression (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (character_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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) declarator: (variable_declarator name: (identifier) value: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier))) declarator: (variable_declarator name: (identifier) value: (field_access object: (array_access array: (identifier) index: (identifier)) field: (identifier)))) (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: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) index: (identifier))))) (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 (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (character_literal) right: (identifier))))))) (break_statement)))))))))