! https://beta.atcoder.jp/contests/abc097/submissions/3768108

module UnionFind
    implicit none
    public
        type :: Union_Find
            integer(8),allocatable,dimension(:) :: par,g
        end type Union_Find
    contains
        subroutine init(p,n)
            implicit none
            type(Union_Find)  p
            integer(8) n,i
            allocate( p%par(n) )
            allocate( p%g(n) )
            do i=1,n
                p%par(i) = i
                p%g(i) = 1
            enddo
        end subroutine init
        recursive function root(p,n) result(ret)
            implicit none
            type(Union_Find) p
            integer(8) ret,n
            if(p%par(n)==n)then
                ret = n
                return
            else
                p%par(n) = root(p,p%par(n))
                ret = p%par(n)
                return
            endif
        end
        function gsize(p,x) result(a)
            implicit none
            integer(8) x,a
            type(Union_Find) p
            a = p%g(root(p,x))
        end
        subroutine unite(p,a,b)
            implicit none
            type(Union_Find) p
            integer(8) a,b
            a = root(p,a)
            b = root(p,b)
            if(a/=b)then
                p%par(a) = b
                p%g(b) = p%g(b) + p%g(a)
                p%g(a) = 0
            endif
        end
end module UnionFind

program atcoder_abc97d
    use UnionFind
    implicit none
    type(Union_Find) uf
    integer(8) n,m,i
    integer(8) ans,x,y
    integer(8),allocatable,dimension(:) :: a,b
    integer(8),allocatable,dimension(:) :: c
    read*,n,m
    allocate( a(m) , b(m) , c(m) )
    call init(uf,n+1)
    do i = 1,m
        read*,a(i),b(i)
    enddo
    ans = (n-1)*n/2
    do i=m,1,-1
        c(i) = ans
        x = gsize(uf,a(i))
        y = gsize(uf,b(i))
        if(root(uf,a(i)) /= root(uf,b(i)))then
            ans = ans - x*y
        endif
        call unite(uf,a(i),b(i))
    enddo
    do i=1,M
        write(*,'(I0)')c(i)
    enddo
!----------------------functions--------------------------
contains
end program atcoder_abc97d