public static void main ( String args [ ] ) throws IOException {
  init ( ) ;
  BufferedReader BR = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  StringTokenizer ST ;
  PrintWriter out = new PrintWriter ( System . out ) ;
  int q , l , r , k ;
  q = Integer . parseInt ( BR . readLine ( ) ) ;
  while ( q -- > 0 ) {
    ST = new StringTokenizer ( BR . readLine ( ) ) ;
    l = Integer . parseInt ( ST . nextToken ( ) ) ;
    r = Integer . parseInt ( ST . nextToken ( ) ) ;
    k = Integer . parseInt ( ST . nextToken ( ) ) ;
    out . println ( ans [ k ] [ r ] - ans [ k ] [ l - 1 ] ) ;
  }
  out . close ( ) ;
}

public static void main ( String args [ ] ) throws IOException { init ( ) ; BufferedReader BR = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer ST ; PrintWriter out = new PrintWriter ( System . out ) ; int q , l , r , k ; q = Integer . parseInt ( BR . readLine ( ) ) ; while ( q -- > 0 ) { ST = new StringTokenizer ( BR . readLine ( ) ) ; l = Integer . parseInt ( ST . nextToken ( ) ) ; r = Integer . parseInt ( ST . nextToken ( ) ) ; k = Integer . parseInt ( ST . nextToken ( ) ) ; out . println ( ans [ k ] [ r ] - ans [ k ] [ l - 1 ] ) ; } out . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (throws (type_identifier)) body: (block (expression_statement (method_invocation 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 (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))) (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: (integral_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (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 (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 (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))