import Control.Monad
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main = do
  [n,m] <- map read.words <$> getLine
  passes <- replicateM m $ (\[a,b]->(a-1,b-1)).map read.words <$> getLine
  mapM_ print $ reverse $ solve (V.fromList $ zip3 [0..n-1] (repeat 0) (repeat 1)) (reverse passes) (fromIntegral n*(fromIntegral n-1)`div`2)

solve :: Vector(Int,Int,Integer) -> [(Int,Int)] -> Integer -> [Integer]
solve _ [] _ = []
solve ids (p@(a,b):ps) dc
  | ap == bp  = dc : solve ids ps dc
  | otherwise = dc : solve unite ps (dc - as * bs)
  where
  ((ap,ar,as),ids') = find a ids []
  ((bp,br,bs),ids'') = find b ids' []
  unite
    | ar >= br = ids'' // [(ap,(ap,ar,as+bs)),(bp,(ap,0,0))]
    | ar < br = ids'' // [(ap,(bp,0,0)),(bp,(bp,br,as+bs))]
    | ap == bp = ids''

find a ids as
  | a == ap = (ag, ids // map (\(a,b,c)->(a,(ap,b,c))) as )
  | otherwise = find ap ids (ag:as)
  where ag@(ap,_,_) = ids!a

root a ids = par
  where (par,_,_) = fst $ find a ids []

size a ids = siz
  where (_,_,siz) = fst $ find a ids []
