public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int N = sc . nextInt ( ) ;
  int M = sc . nextInt ( ) ;
  int [ ] [ ] A = new int [ M ] [ 2 ] ;
  for ( int i = 0 ;
  i < M ;
  i ++ ) {
    A [ i ] [ 0 ] = sc . nextInt ( ) - 1 ;
    A [ i ] [ 1 ] = sc . nextInt ( ) - 1 ;
  }
  int [ ] [ ] B = new int [ N ] [ 2 ] ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    B [ i ] [ 0 ] = i ;
    B [ i ] [ 1 ] = 1 ;
  }
  long [ ] inconv = new long [ M + 1 ] ;
  inconv [ M ] = ( long ) N * ( N - 1 ) / 2 ;
  for ( int i = M - 1 ;
  i >= 0 ;
  i -- ) {
    int v1 = A [ i ] [ 0 ] ;
    int v2 = A [ i ] [ 1 ] ;
    int l1 = findRoot ( B , B [ v1 ] [ 0 ] ) ;
    int l2 = findRoot ( B , B [ v2 ] [ 0 ] ) ;
    inconv [ i ] = inconv [ i + 1 ] ;
    if ( l1 != l2 ) {
      int s1 = B [ l1 ] [ 1 ] ;
      int s2 = B [ l2 ] [ 1 ] ;
      inconv [ i ] -= s1 * s2 ;
      if ( s1 < s2 ) {
        int temp = l1 ;
        l1 = l2 ;
        l2 = temp ;
      }
      B [ l1 ] [ 1 ] += B [ l2 ] [ 1 ] ;
      B [ l2 ] [ 0 ] = l1 ;
      B [ l2 ] [ 1 ] = 0 ;
    }
  }
  for ( int i = 1 ;
  i < M + 1 ;
  i ++ ) {
    System . out . println ( inconv [ i ] ) ;
  }
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] A = new int [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] [ 0 ] = sc . nextInt ( ) - 1 ; A [ i ] [ 1 ] = sc . nextInt ( ) - 1 ; } int [ ] [ ] B = new int [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { B [ i ] [ 0 ] = i ; B [ i ] [ 1 ] = 1 ; } long [ ] inconv = new long [ M + 1 ] ; inconv [ M ] = ( long ) N * ( N - 1 ) / 2 ; for ( int i = M - 1 ; i >= 0 ; i -- ) { int v1 = A [ i ] [ 0 ] ; int v2 = A [ i ] [ 1 ] ; int l1 = findRoot ( B , B [ v1 ] [ 0 ] ) ; int l2 = findRoot ( B , B [ v2 ] [ 0 ] ) ; inconv [ i ] = inconv [ i + 1 ] ; if ( l1 != l2 ) { int s1 = B [ l1 ] [ 1 ] ; int s2 = B [ l2 ] [ 1 ] ; inconv [ i ] -= s1 * s2 ; if ( s1 < s2 ) { int temp = l1 ; l1 = l2 ; l2 = temp ; } B [ l1 ] [ 1 ] += B [ l2 ] [ 1 ] ; B [ l2 ] [ 0 ] = l1 ; B [ l2 ] [ 1 ] = 0 ; } } for ( int i = 1 ; i < M + 1 ; i ++ ) { System . out . println ( inconv [ i ] ) ; } }
(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: (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)))) (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)) 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: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) 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)) 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: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) 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)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (binary_expression left: (cast_expression type: (integral_type) value: (identifier)) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) 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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))))))