{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  abs <- replicateM m $ (\(a:b:_) -> (a,b)) . map read . words <$> getLine :: IO [(Int, Int)]
  putStr . unlines . map show $ solve' n m abs
  -- solve n m abs
  -- return ()

solve' n m abs = tail . reverse . scanl (-) (pairs n) $ unfoldr f (initial, reverse abs)
  where
    initial = ufFromList [1..n]
    f :: (UnionFind Int, [(Int, Int)]) -> Maybe (Int, (UnionFind Int, [(Int, Int)]))
    f (_, []) = Nothing
    f (uf, (a,b):abs) = Just (if pa == pb then 0 else na * nb, (newUf, abs))
      where
        (pa, na) = ufFindImpl a uf
        (pb, nb) = ufFindImpl b uf
        newUf = ufUnite a b uf

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

type UnionFind a = Map.Map a (a, Int)

ufFromList :: (Ord a) => [a] -> UnionFind a
ufFromList as = Map.fromList $ zip as $ zip as (repeat 1)

ufIsRoot :: (Ord a) => a -> UnionFind a -> Bool
ufIsRoot k uf = k == (fst $ uf Map.! k)

ufFindImpl :: (Ord a) => a -> UnionFind a -> (a, Int)
ufFindImpl k uf | ufIsRoot k uf = uf Map.! k
                | otherwise = ufFindImpl (fst $ uf Map.! k) uf

ufFind :: (Ord a) => a -> UnionFind a -> a
ufFind k uf = fst $ ufFindImpl k uf

ufSize :: (Ord a) => a -> UnionFind a -> Int
ufSize k uf = snd $ ufFindImpl k uf

ufUnite :: (Ord a) => a -> a -> UnionFind a -> UnionFind a
ufUnite k l uf 
  | (ufFind k uf) == (ufFind l uf) = uf
  | otherwise = if nk < nl 
                then Map.adjust (\_ -> (pl, nk + nl)) pl $ Map.adjust (\_ -> (pl, 0)) pk uf
                else Map.adjust (\_ -> (pk, nk + nl)) pk $ Map.adjust (\_ -> (pk, 0)) pl uf
    where
      (pk, nk) = ufFindImpl k uf
      (pl, nl) = ufFindImpl l uf
