public static void solve ( ) {
  int n = s . nextInt ( ) ;
  HashMap < Integer , Integer > map1 = new HashMap < > ( ) ;
  HashMap < Integer , Integer > map2 = new HashMap < > ( ) ;
  while ( n -- > 0 ) {
    int a = s . nextInt ( ) ;
    int b = s . nextInt ( ) ;
    if ( map1 . containsKey ( a ) ) {
      map1 . replace ( a , 1 ) ;
    }
    else map1 . put ( a , 1 ) ;
    if ( map2 . containsKey ( b ) ) {
      map2 . replace ( b , 1 ) ;
    }
    else map2 . put ( b , 1 ) ;
  }
  System . out . println ( Math . min ( map1 . size ( ) , map2 . size ( ) ) ) ;
}

public static void solve ( ) { int n = s . nextInt ( ) ; HashMap < Integer , Integer > map1 = new HashMap < > ( ) ; HashMap < Integer , Integer > map2 = new HashMap < > ( ) ; while ( n -- > 0 ) { int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; if ( map1 . containsKey ( a ) ) { map1 . replace ( a , 1 ) ; } else map1 . put ( a , 1 ) ; if ( map2 . containsKey ( b ) ) { map2 . replace ( b , 1 ) ; } else map2 . put ( b , 1 ) ; } System . out . println ( Math . min ( map1 . size ( ) , map2 . size ( ) ) ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) 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: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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) value: (method_invocation object: (identifier) name: (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)))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) alternative: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))))