class UnionFind:

  def __init__(self,n):

    *self.table,=range(n)

    self.rank=[1]*n

  def root(self,x):

    if self.table[x]==x:

      return x

    else:

      self.table[x]=self.root(self.table[x])

      return self.table[x]

  def unite(self,x,y):

    x=self.root(x)

    y=self.root(y)

    if x!=y:

      if self.rank[x]<self.rank[y]:

        x,y=y,x

      self.rank[x]+=self.rank[y]

      self.table[y]=x

  def same(self,x,y):

    return self.root(x)==self.root(y)

  def size(self,x):

    return self.rank[self.root(x)]

(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]

u=UnionFind(n)

a=[n*~-n//2]

for x,y in e[::-1]:

  x,y=x-1,y-1

  t=a[-1]

  if not u.same(x,y):

    t-=u.size(x)*u.size(y)

  a.append(t)

  u.unite(x,y)

print(*a[::-1],sep='\n')

def root(x):

  if table[x]==x:

    return x

  else:

    table[x]=root(table[x])

    return table[x]

def unite(x,y):

  x=root(x)

  y=root(y)

  if x!=y:

    if rank[x]<rank[y]:

      x,y=y,x

    rank[x]+=rank[y]

    table[y]=x

def same(x,y):

  return root(x)==root(y)

def size(x):

  return rank[root(x)]

(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]

*table,=range(n)

rank=[1]*n

a=[n*~-n//2]

for x,y in e[::-1]:

  x,y=x-1,y-1

  t=a[-1]

  if not same(x,y):

    t-=size(x)*size(y)

  a.append(t)

  unite(x,y)

print(*a[::-1],sep='\n')

class UnionFind:
    def __init__(self, n):
        (*self.table,) = range(n)
        self.rank = [1] * n

    def root(self, x):
        if self.table[x] == x:
            return x
        else:
            self.table[x] = self.root(self.table[x])
            return self.table[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.rank[x] += self.rank[y]
            self.table[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return self.rank[self.root(x)]


(n, m), _, *e = [map(int, t.split()) for t in open(0).readlines()]
u = UnionFind(n)
a = [n * ~-n // 2]
for x, y in e[::-1]:
    x, y = x - 1, y - 1
    t = a[-1]
    if not u.same(x, y):
        t -= u.size(x) * u.size(y)
    a.append(t)
    u.unite(x, y)
print(*a[::-1], sep="\n")

def root(x):
    if table[x] == x:
        return x
    else:
        table[x] = root(table[x])
        return table[x]


def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        if rank[x] < rank[y]:
            x, y = y, x
        rank[x] += rank[y]
        table[y] = x


def same(x, y):
    return root(x) == root(y)


def size(x):
    return rank[root(x)]


(n, m), _, *e = [map(int, t.split()) for t in open(0).readlines()]
(*table,) = range(n)
rank = [1] * n
a = [n * ~-n // 2]
for x, y in e[::-1]:
    x, y = x - 1, y - 1
    t = a[-1]
    if not same(x, y):
        t -= size(x) * size(y)
    a.append(t)
    unite(x, y)
print(*a[::-1], sep="\n")

-class UnionFind: -    def __init__(self, n): -        (*self.table,) = range(n) -        self.rank = [1] * n +def root(x): +    if table[x] == x: +        return x +    else: +        table[x] = root(table[x]) +        return table[x] -    def root(self, x): -        if self.table[x] == x: -            return x -        else: -            self.table[x] = self.root(self.table[x]) -            return self.table[x] -    def unite(self, x, y): -        x = self.root(x) -        y = self.root(y) -        if x != y: -            if self.rank[x] < self.rank[y]: -                x, y = y, x -            self.rank[x] += self.rank[y] -            self.table[y] = x +def unite(x, y): +    x = root(x) +    y = root(y) +    if x != y: +        if rank[x] < rank[y]: +            x, y = y, x +        rank[x] += rank[y] +        table[y] = x -    def same(self, x, y): -        return self.root(x) == self.root(y) -    def size(self, x): -        return self.rank[self.root(x)] +def same(x, y): +    return root(x) == root(y) + + +def size(x): +    return rank[root(x)] -u = UnionFind(n) +(*table,) = range(n) +rank = [1] * n -    if not u.same(x, y): -        t -= u.size(x) * u.size(y) +    if not same(x, y): +        t -= size(x) * size(y) -    u.unite(x, y) +    unite(x, y)