{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import Data.Foldable (foldl')
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import Debug.Trace

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread i v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite i a v = accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uswap :: VUM.Unbox a => Int -> Int -> VUM.IOVector a -> VUM.IOVector a
uswap i j v = accursedUnutterablePerformIO $ VUM.unsafeSwap v i j >> return v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw v = accursedUnutterablePerformIO $ VU.unsafeThaw v

newtype UnionFind = UnionFind (VUM.IOVector Int, VUM.IOVector Int)

findUF :: UnionFind -> Int -> Int
findUF (UnionFind (elems, _)) k = fix
  ( \f (elems, k, path) -> case uread k elems of
    n | n == k -> foldl' (\acc p -> uwrite p n acc) elems path `seq` n
    n          -> f (elems, n, n : path)
  )
  (elems, k, [k])

sizeUF :: UnionFind -> Int -> Int
sizeUF uf@(UnionFind (_, sizes)) i = uread (findUF uf i) sizes

unionUF :: UnionFind -> Int -> Int -> UnionFind
unionUF uf@(UnionFind (elem, sizes)) i j =
  let pi = findUF uf i
      pj = findUF uf j
      si = uread pi sizes
      sj = uread pj sizes
  in  if pi == pj
        then uf
        else
          let (t1, t2) = if si < sj then (pi, pj) else (pj, pi)
          in  UnionFind (uwrite t1 t2 elem, uwrite t2 (si + sj) sizes)

solve :: Int -> Int -> VU.Vector (Int, Int) -> VU.Vector Int
solve n m abs = VU.init $ ufreeze $ (\(_, _, _, acc) -> acc) $ VU.foldr'
  go
  ( group
  , m - 1
  , nC2
  , uwrite m nC2 $ accursedUnutterablePerformIO $ VUM.unsafeNew (m + 1)
  )
  abs
 where
  go (a, b) (uf, k, prev, acc) =
    let ga  = findUF uf a
        gb  = findUF uf b
        n1  = sizeUF uf a
        n2  = sizeUF uf b
        res = prev - n1 * n2
    in  ( unionUF uf a b
        , k - 1
        , if ga == gb then prev else res
        , uwrite k prev acc
        )

  nC2 = n * (n - 1) `div` 2

  group :: UnionFind
  group = UnionFind
    (uthaw $ VU.enumFromN 0 n, accursedUnutterablePerformIO $ VUM.replicate n 1)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (n, m) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  abs <- VU.replicateM
    m
    (   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine
    )

  VU.mapM_ print $ solve n m abs
