# https://atcoder.jp/contests/abc120/tasks/abc120_d


class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()]





from itertools import combinations
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

data = [map(int, input().split()) for _ in range(M)]

tree = UnionFind(N)

res = []
inconv = N*(N-1)//2

for a, b in reversed(data):                                 # O(M)
    a -= 1
    b -= 1
    if tree.find(a) != tree.find(b):
        inconv -= tree.size(a)*tree.size(b)
        tree.union(a, b)
    res.append(inconv)

res.pop()                                   # 橋が落ちる前の最初の状態については出力しない

for a in reversed(res):
    print(a)

print(N*(N-1)//2)                           # 全ての道が切れた時の不便さを最後に追加

'''

4 5
1 2
3 4
1 3
2 3
1 4

''' class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()] UnionFind def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

     __init__ self.n = n self.n self n n self.parents = [-1]*n self.parents self parents [-1]*n [-1] -1 n self self n n def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

     find if self.parents[x] < 0:
            return x
         self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

     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
         x == y x y return if self.parents[x] > self.parents[y]:
            x, y = y, x
         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x, y = y, x x y y x self.parents[x] += self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x self self x x y y def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

     members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if self.find(i) == root for i in range(self.n) if self.find(i) == root i range(self.n) range self.n self n self.find(i) == root self.find(i) self.find self find i root if self.find(i) == root i return [i for i in range(self.n) if self.find(i) == root] [i for i in range(self.n) if self.find(i) == root] self self x x def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

     roots i for i, x in enumerate(self.parents) if x < 0 for i, x in enumerate(self.parents) if x < 0 i x enumerate(self.parents) enumerate self.parents self parents x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.parents) if x < 0] [i for i, x in enumerate(self.parents) if x < 0] self self def group_count(self):                                      # グループの数を返す
        return len(self.roots())

     group_count return len(self.roots()) len(self.roots()) len self.roots() self.roots self roots self self def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()] all_group_members list(self.members(r)) for r in self.roots() for r in self.roots() r self.roots() self.roots self roots for r in self.roots() list(self.members(r)) list self.members(r) self.members self members r return [list(self.members(r)) for r in self.roots()] [list(self.members(r)) for r in self.roots()] self self from itertools import combinations import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M map(int, input().split()) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) map(int, input().split()) map int input().split() ().split () input split data = [map(int, input().split()) for _ in range(M)] data [map(int, input().split()) for _ in range(M)] tree = UnionFind(N) tree UnionFind(N) UnionFind N res = [] res [] inconv = N*(N-1)//2 inconv N*(N-1)//2 N*(N-1) N N-1 N 1 2 for a, b in reversed(data):                                 # O(M)
    a -= 1
    b -= 1
    if tree.find(a) != tree.find(b):
        inconv -= tree.size(a)*tree.size(b)
        tree.union(a, b)
    res.append(inconv) a b reversed(data) reversed data a -= 1 a 1 b -= 1 b 1 if tree.find(a) != tree.find(b):
        inconv -= tree.size(a)*tree.size(b)
        tree.union(a, b)
     tree.find(a) != tree.find(b) tree.find(a) tree.find tree find a tree.find(b) tree.find tree find b inconv -= tree.size(a)*tree.size(b) inconv tree.size(a)*tree.size(b) tree.size(a) tree.size tree size a tree.size(b) tree.size tree size b tree.union(a, b) tree.union tree union a b res.append(inconv) res.append res append inconv res.pop() res.pop res pop for a in reversed(res):
    print(a) a reversed(res) reversed res print(a) print a print(N*(N-1)//2) print N*(N-1)//2 N*(N-1) N N-1 N 1 2 '''

4 5
1 2
3 4
1 3
2 3
1 4

''' data = [map(int, input().split()) for _ in range(M)] [map(int, input().split()) for _ in range(M)] data class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()] class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()] UnionFind b -= 1 1 b res = [] [] res input = sys.stdin.readline sys.stdin.readline input a -= 1 1 a M = map(int, input().split()) map(int, input().split()) M tree = UnionFind(N) UnionFind(N) tree inconv -= tree.size(a)*tree.size(b) tree.size(a)*tree.size(b) inconv N, M = map(int, input().split()) map(int, input().split()) N inconv = N*(N-1)//2 N*(N-1)//2 inconv
# https://atcoder.jp/contests/abc120/tasks/abc120_d


class UnionFind():

    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}をリストで返す
        return [list(self.members(r)) for r in self.roots()]





from itertools import combinations
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

data = [map(int, input().split()) for _ in range(M)]

tree = UnionFind(N)

res = []
inconv = N*(N-1)//2

for a, b in reversed(data):                                 # O(M)
    a -= 1
    b -= 1
    if tree.find(a) != tree.find(b):
        inconv -= tree.size(a)*tree.size(b)
        tree.union(a, b)
    res.append(inconv)

res.pop()                                   # 橋が落ちる前の最初の状態については出力しない

for a in reversed(res):
    print(a)

print(N*(N-1)//2)                           # 全ての道が切れた時の不便さを最後に追加

'''

4 5
1 2
3 4
1 3
2 3
1 4

'''