public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  String [ ] rck = scanner . nextLine ( ) . split ( " " , 3 ) ;
  int R = Integer . parseInt ( rck [ 0 ] ) ;
  int C = Integer . parseInt ( rck [ 1 ] ) ;
  int K = Integer . parseInt ( rck [ 2 ] ) ;
  int N = Integer . parseInt ( scanner . nextLine ( ) ) ;
  int [ ] countPerR = new int [ R + 1 ] ;
  int [ ] countPerC = new int [ C + 1 ] ;
  int [ ] Rs = new int [ N ] ;
  int [ ] Cs = new int [ N ] ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    String [ ] rc = scanner . nextLine ( ) . split ( " " , 2 ) ;
    int r = Integer . parseInt ( rc [ 0 ] ) ;
    int c = Integer . parseInt ( rc [ 1 ] ) ;
    countPerR [ r ] ++ ;
    countPerC [ c ] ++ ;
    Rs [ i ] = r ;
    Cs [ i ] = c ;
  }
  long [ ] rPerCount = new long [ N + 1 ] ;
  for ( int i = 1 ;
  i <= R ;
  i ++ ) {
    rPerCount [ countPerR [ i ] ] ++ ;
  }
  long [ ] cPerCount = new long [ N + 1 ] ;
  for ( int i = 1 ;
  i <= C ;
  i ++ ) {
    cPerCount [ countPerC [ i ] ] ++ ;
  }
  long result = 0 ;
  for ( int i = 0 ;
  i <= K ;
  i ++ ) {
    result += rPerCount [ i ] * cPerCount [ K - i ] ;
  }
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    int r = Rs [ i ] ;
    int c = Cs [ i ] ;
    long count = countPerR [ r ] + countPerC [ c ] ;
    if ( count == K ) {
      result -- ;
    }
    else if ( count == K + 1 ) {
      result ++ ;
    }
  }
  System . out . println ( result ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] rck = scanner . nextLine ( ) . split ( " ▁ " , 3 ) ; int R = Integer . parseInt ( rck [ 0 ] ) ; int C = Integer . parseInt ( rck [ 1 ] ) ; int K = Integer . parseInt ( rck [ 2 ] ) ; int N = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] countPerR = new int [ R + 1 ] ; int [ ] countPerC = new int [ C + 1 ] ; int [ ] Rs = new int [ N ] ; int [ ] Cs = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String [ ] rc = scanner . nextLine ( ) . split ( " ▁ " , 2 ) ; int r = Integer . parseInt ( rc [ 0 ] ) ; int c = Integer . parseInt ( rc [ 1 ] ) ; countPerR [ r ] ++ ; countPerC [ c ] ++ ; Rs [ i ] = r ; Cs [ i ] = c ; } long [ ] rPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= R ; i ++ ) { rPerCount [ countPerR [ i ] ] ++ ; } long [ ] cPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= C ; i ++ ) { cPerCount [ countPerC [ i ] ] ++ ; } long result = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { result += rPerCount [ i ] * cPerCount [ K - i ] ; } for ( int i = 0 ; i < N ; i ++ ) { int r = Rs [ i ] ; int c = Cs [ i ] ; long count = countPerR [ r ] + countPerC [ c ] ; if ( count == K ) { result -- ; } else if ( count == K + 1 ) { result ++ ; } } System . out . println ( result ) ; }
(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: (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) (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (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)))))) (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)))))) (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 (identifier))))) (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 (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: (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) (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))) (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)))))) (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: (identifier) index: (array_access array: (identifier) index: (identifier))))))) (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)))))) (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: (identifier) index: (array_access array: (identifier) index: (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: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (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: (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (update_expression (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (update_expression (identifier)))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))