

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

      
n, m = map(int, input().split())
b = UnionFind(n)
comb = n*(n-1)//2
bridge = [list(map(int, input().split())) for i in range(m)]
rev = bridge[::-1]
ans = [0]*m 
ans[-1] = comb
for i in range(m-1):
  x, y = rev[i]
  if b.same_check(x, y):
      ans[-(i+2)]=ans[-(i+1)]
  else:
      s=b.num[b.find(x)]
      t=b.num[b.find(y)]
      ans[-(i+2)]=ans[-(i+1)]-s*t
      b.union(x, y)
for i in range(m):
  print(ans[i]) class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

       UnionFind def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
     __init__ i for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) i self.par = [i for i in range(n+1)] self.par self par [i for i in range(n+1)] self.rank = [0] * (n+1) self.rank self rank [0] * (n+1) [0] 0 n+1 n 1 self.num = [1] * (n+1) self.num self num [1] * (n+1) [1] 1 n+1 n 1 self self n n def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
     find if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
     self.par[x] == x self.par[x] self.par self par x x return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
     union x = self.find(x) x self.find(x) self.find self find x y = self.find(y) y self.find(y) self.find self find y if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
     self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.par[x] = y self.par[x] self.par self par x y self.num[y]+=self.num[x] self.num[y] self.num self num y self.num[x] self.num self num x self.par[y] = x self.par[y] self.par self par y x self.num[x]+=self.num[y] self.num[x] self.num self num x self.num[y] self.num self num y if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
     self.rank[x] == self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x] += 1 self.rank[x] self.rank self rank x 1 self self x x y y def same_check(self, x, y):
        return self.find(x) == self.find(y)

       same_check return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m b = UnionFind(n) b UnionFind(n) UnionFind n comb = n*(n-1)//2 comb n*(n-1)//2 n*(n-1) n n-1 n 1 2 list(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bridge = [list(map(int, input().split())) for i in range(m)] bridge [list(map(int, input().split())) for i in range(m)] rev = bridge[::-1] rev bridge[::-1] bridge ::-1 -1 ans = [0]*m ans [0]*m [0] 0 m ans[-1] = comb ans[-1] ans -1 comb for i in range(m-1):
  x, y = rev[i]
  if b.same_check(x, y):
      ans[-(i+2)]=ans[-(i+1)]
  else:
      s=b.num[b.find(x)]
      t=b.num[b.find(y)]
      ans[-(i+2)]=ans[-(i+1)]-s*t
      b.union(x, y) i range(m-1) range m-1 m 1 x, y = rev[i] x rev[i] rev i y if b.same_check(x, y):
      ans[-(i+2)]=ans[-(i+1)]
  else:
      s=b.num[b.find(x)]
      t=b.num[b.find(y)]
      ans[-(i+2)]=ans[-(i+1)]-s*t
      b.union(x, y) b.same_check(x, y) b.same_check b same_check x y ans[-(i+2)]=ans[-(i+1)] ans[-(i+2)] ans -(i+2) i+2 i 2 ans[-(i+1)] ans -(i+1) i+1 i 1 s=b.num[b.find(x)] s b.num[b.find(x)] b.num b num b.find(x) b.find b find x t=b.num[b.find(y)] t b.num[b.find(y)] b.num b num b.find(y) b.find b find y ans[-(i+2)]=ans[-(i+1)]-s*t ans[-(i+2)] ans -(i+2) i+2 i 2 ans[-(i+1)]-s*t ans[-(i+1)] ans -(i+1) i+1 i 1 s*t s t b.union(x, y) b.union b union x y for i in range(m):
  print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i comb = n*(n-1)//2 n*(n-1)//2 comb ans = [0]*m [0]*m ans class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

       class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

       UnionFind bridge = [list(map(int, input().split())) for i in range(m)] [list(map(int, input().split())) for i in range(m)] bridge y = rev[i] rev[i] y n, m = map(int, input().split()) map(int, input().split()) n rev = bridge[::-1] bridge[::-1] rev t=b.num[b.find(y)] b.num[b.find(y)] t m = map(int, input().split()) map(int, input().split()) m s=b.num[b.find(x)] b.num[b.find(x)] s b = UnionFind(n) UnionFind(n) b x, y = rev[i] rev[i] x


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.num = [1] * (n+1)#集合の要素の数

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.num[y]+=self.num[x]
        else:
            self.par[y] = x
            self.num[x]+=self.num[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

      
n, m = map(int, input().split())
b = UnionFind(n)
comb = n*(n-1)//2
bridge = [list(map(int, input().split())) for i in range(m)]
rev = bridge[::-1]
ans = [0]*m 
ans[-1] = comb
for i in range(m-1):
  x, y = rev[i]
  if b.same_check(x, y):
      ans[-(i+2)]=ans[-(i+1)]
  else:
      s=b.num[b.find(x)]
      t=b.num[b.find(y)]
      ans[-(i+2)]=ans[-(i+1)]-s*t
      b.union(x, y)
for i in range(m):
  print(ans[i])