class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
res = n*(n-1)//2
ans = []
ans.append(res)
for i in range(1, m)[::-1]:
    a = ab[i][0]
    b = ab[i][1]
    if not uf.same_check(a, b):
        res -= uf.size(a)*uf.size(b)
    uf.union(a, b)
    ans.append(res)
ans.reverse()
for i in range(m):
    print(ans[i])
 class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)] UnionFind def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

     __init__ self.par = [-1] * (n + 1) self.par self par [-1] * (n + 1) [-1] -1 n + 1 n 1 self.rank = [0] * (n + 1) self.rank self rank [0] * (n + 1) [0] 0 n + 1 n 1 self self n n def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])  # 再帰で根までたどる.その過程で根とつなぎかえる
            return self.par[x]

     find if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])  # 再帰で根までたどる.その過程で根とつなぎかえる
            return self.par[x]

     self.par[x] < 0 self.par[x] self.par self par x 0 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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

     x == y x y return if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                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[y] += self.par[x] self.par[y] self.par self par y self.par[x] self.par self par x self.par[x] = y self.par[x] self.par self par x y self.par[x] += self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y self.par[y] = x self.par[y] self.par self par y x 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)  # 根同じならTrue違うならFalseを返す

     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 def size(self, x):
        return -self.par[self.find(x)] size return -self.par[self.find(x)] -self.par[self.find(x)] self.par[self.find(x)] self.par self par self.find(x) self.find self find x self self x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ab = [list(map(int, input().split())) for _ in range(m)] ab [list(map(int, input().split())) for _ in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n res = n*(n-1)//2 res n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans = [] ans [] ans.append(res) ans.append ans append res for i in range(1, m)[::-1]:
    a = ab[i][0]
    b = ab[i][1]
    if not uf.same_check(a, b):
        res -= uf.size(a)*uf.size(b)
    uf.union(a, b)
    ans.append(res) i range(1, m)[::-1] (1, m) range 1 m ::-1 -1 a = ab[i][0] a ab[i][0] [i] ab i 0 b = ab[i][1] b ab[i][1] [i] ab i 1 if not uf.same_check(a, b):
        res -= uf.size(a)*uf.size(b)
     not uf.same_check(a, b) uf.same_check(a, b) uf.same_check uf same_check a b res -= uf.size(a)*uf.size(b) res uf.size(a)*uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b ans.append(res) ans.append ans append res ans.reverse() ans.reverse ans reverse for i in range(m):
    print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i res = n*(n-1)//2 n*(n-1)//2 res uf = UnionFind(n) UnionFind(n) uf b = ab[i][1] ab[i][1] b ab = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ab ans = [] [] ans res -= uf.size(a)*uf.size(b) uf.size(a)*uf.size(b) res class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)] class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)] UnionFind n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m a = ab[i][0] ab[i][0] a
class UnionFind:
    def __init__(self, n):
        self.par = [-1] * (n + 1)  # 頂点番号とindexをそろえるためにn+1
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.par[x] < 0:
            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 x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = UnionFind(n)
res = n*(n-1)//2
ans = []
ans.append(res)
for i in range(1, m)[::-1]:
    a = ab[i][0]
    b = ab[i][1]
    if not uf.same_check(a, b):
        res -= uf.size(a)*uf.size(b)
    uf.union(a, b)
    ans.append(res)
ans.reverse()
for i in range(m):
    print(ans[i])

