public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  String s [ ] = scanner . nextLine ( ) . split ( " " ) ;
  int n = Integer . parseInt ( s [ 0 ] ) ;
  int m = Integer . parseInt ( s [ 1 ] ) ;
  int arr [ ] [ ] = new int [ m ] [ 2 ] ;
  for ( int i = 0 ;
  i < m ;
  i ++ ) {
    s = scanner . nextLine ( ) . split ( " " ) ;
    arr [ i ] [ 0 ] = Integer . parseInt ( s [ 0 ] ) ;
    arr [ i ] [ 1 ] = Integer . parseInt ( s [ 1 ] ) ;
  }
  int res = 0 ;
  for ( int i = 1 ;
  i <= 100 ;
  i ++ ) {
    if ( judge ( i , arr , m ) ) {
      int temp = n % i == 0 ? n / i : n / i + 1 ;
      if ( res == 0 ) {
        res = temp ;
      }
      else if ( temp != res ) {
        System . out . println ( - 1 ) ;
        return ;
      }
    }
  }
  if ( res == 0 ) res = - 1 ;
  System . out . println ( res ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s [ ] = scanner . nextLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( s [ 0 ] ) ; int m = Integer . parseInt ( s [ 1 ] ) ; int arr [ ] [ ] = new int [ m ] [ 2 ] ; for ( int i = 0 ; i < m ; i ++ ) { s = scanner . nextLine ( ) . split ( " ▁ " ) ; arr [ i ] [ 0 ] = Integer . parseInt ( s [ 0 ] ) ; arr [ i ] [ 1 ] = Integer . parseInt ( s [ 1 ] ) ; } int res = 0 ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( judge ( i , arr , m ) ) { int temp = n % i == 0 ? n / i : n / i + 1 ; if ( res == 0 ) { res = temp ; } else if ( temp != res ) { System . out . println ( - 1 ) ; return ; } } } if ( res == 0 ) res = - 1 ; System . out . println ( res ) ; }
(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: (type_identifier) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_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) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier)) 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 (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (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: (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 (if_statement condition: (parenthesized_expression (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) consequence: (binary_expression left: (identifier) right: (identifier)) alternative: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (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 (unary_expression operand: (decimal_integer_literal))))) (return_statement)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))