from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)})

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

uf = UnionFind(n)
inc = [n * (n - 1) // 2] * m
for i in range(m - 1):
    a, b = ab[- i - 1]
    rec = uf.union(a, b)
    if rec == -1:
        inc[-i-2] = inc[-i-1]
        continue

    temp = rec[1] - rec[0]
    inc[-i-2] = max(inc[-i-1] - temp * rec[0], 0)

    #print(uf.size,inc,rec,temp)
print(*inc, sep = '\n') from sys import setrecursionlimit class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)}) UnionFind def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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.size = [1] * (n + 1) self.size self size [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


     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 union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

     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 -1
        # rankの小さいものを大きいほうにくっつける
         x == y x y if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[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[x] = y self.par[x] self.par self par x y temp = self.size[x] temp self.size[x] self.size self size x self.size[y] += temp self.size[y] self.size self size y temp temp1 = self.size[y] temp1 self.size[y] self.size self size y self.par[y] = x self.par[y] self.par self par y x temp = self.size[y] temp self.size[y] self.size self size y self.size[x] += temp self.size[x] self.size self size x temp temp1 = self.size[x] temp1 self.size[x] self.size self size 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 return (temp, temp1) (temp, temp1) temp temp1 self self x x y y def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)}) count_group self.find(x) for x in range(1, n + 1) for x in range(1, n + 1) x range(1, n + 1) range 1 n + 1 n 1 for x in range(1, n + 1) self.find(x) self.find self find x return len({self.find(x) for x in range(1, n + 1)}) len({self.find(x) for x in range(1, n + 1)}) len self self 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 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 ab = [list(map(int,input().split())) for i in range(m)] ab [list(map(int,input().split())) for i in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n inc = [n * (n - 1) // 2] * m inc [n * (n - 1) // 2] * m [n * (n - 1) // 2] n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 m for i in range(m - 1):
    a, b = ab[- i - 1]
    rec = uf.union(a, b)
    if rec == -1:
        inc[-i-2] = inc[-i-1]
        continue

    temp = rec[1] - rec[0]
    inc[-i-2] = max(inc[-i-1] - temp * rec[0], 0)

    #print(uf.size,inc,rec,temp) i range(m - 1) range m - 1 m 1 a, b = ab[- i - 1] a ab[- i - 1] ab - i - 1 - i i 1 b rec = uf.union(a, b) rec uf.union(a, b) uf.union uf union a b if rec == -1:
        inc[-i-2] = inc[-i-1]
        continue

     rec == -1 rec -1 inc[-i-2] = inc[-i-1] inc[-i-2] inc -i-2 -i i 2 inc[-i-1] inc -i-1 -i i 1 continue temp = rec[1] - rec[0] temp rec[1] - rec[0] rec[1] rec 1 rec[0] rec 0 inc[-i-2] = max(inc[-i-1] - temp * rec[0], 0) inc[-i-2] inc -i-2 -i i 2 max(inc[-i-1] - temp * rec[0], 0) max inc[-i-1] - temp * rec[0] inc[-i-1] inc -i-1 -i i 1 temp * rec[0] temp rec[0] rec 0 0 print(*inc, sep = '\n') print *inc inc sep = '\n' sep '\n' rec = uf.union(a, b) uf.union(a, b) rec temp = rec[1] - rec[0] rec[1] - rec[0] temp class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)}) class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)}) UnionFind n, m = map(int,input().split()) map(int,input().split()) n ab = [list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] ab inc = [n * (n - 1) // 2] * m [n * (n - 1) // 2] * m inc a, b = ab[- i - 1] ab[- i - 1] a m = map(int,input().split()) map(int,input().split()) m uf = UnionFind(n) UnionFind(n) uf b = ab[- i - 1] ab[- i - 1] b
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [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 check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return -1
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            temp = self.size[x]
            self.size[y] += temp
            temp1 = self.size[y]
        else:
            self.par[y] = x
            temp = self.size[y]
            self.size[x] += temp
            temp1 = self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return (temp, temp1)

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)})

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

uf = UnionFind(n)
inc = [n * (n - 1) // 2] * m
for i in range(m - 1):
    a, b = ab[- i - 1]
    rec = uf.union(a, b)
    if rec == -1:
        inc[-i-2] = inc[-i-1]
        continue

    temp = rec[1] - rec[0]
    inc[-i-2] = max(inc[-i-1] - temp * rec[0], 0)

    #print(uf.size,inc,rec,temp)
print(*inc, sep = '\n')
