class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())

bridges = []
for i in range(m):
    a, b = map(int, input().split())
    bridges.append((a-1, b-1))

uf = UnionFind(n)
ans = [n * (n-1) // 2]
for a, b in bridges[::-1]:
    a1 = uf.get_size(a)
    b1 = uf.get_size(b)
    uf.union(a, b)
    a2 = uf.get_size(a)
    b2 = uf.get_size(b)

    conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2
    ans.append(ans[-1]-conv)

print('\n'.join(map(str, ans[-2::-1]))) class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x] UnionFind def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.par = [i for i in range(n)] self.par self par [i for i in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 self.rank = [0 for _ in range(n)] self.rank self rank [0 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self.size = [1 for _ in range(n)] self.size self size [1 for _ in range(n)] self self n=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]

     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 x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

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

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

     is_same 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 get_size(self, x):
        x = self.find(x)
        return self.size[x] get_size x = self.find(x) x self.find(x) self.find self find x return self.size[x] self.size[x] self.size self size x self self x x object n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m bridges = [] bridges [] for i in range(m):
    a, b = map(int, input().split())
    bridges.append((a-1, b-1)) i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b bridges.append((a-1, b-1)) bridges.append bridges append (a-1, b-1) a-1 a 1 b-1 b 1 uf = UnionFind(n) uf UnionFind(n) UnionFind n ans = [n * (n-1) // 2] ans [n * (n-1) // 2] n * (n-1) // 2 n * (n-1) n n-1 n 1 2 for a, b in bridges[::-1]:
    a1 = uf.get_size(a)
    b1 = uf.get_size(b)
    uf.union(a, b)
    a2 = uf.get_size(a)
    b2 = uf.get_size(b)

    conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2
    ans.append(ans[-1]-conv) a b bridges[::-1] bridges ::-1 -1 a1 = uf.get_size(a) a1 uf.get_size(a) uf.get_size uf get_size a b1 = uf.get_size(b) b1 uf.get_size(b) uf.get_size uf get_size b uf.union(a, b) uf.union uf union a b a2 = uf.get_size(a) a2 uf.get_size(a) uf.get_size uf get_size a b2 = uf.get_size(b) b2 uf.get_size(b) uf.get_size uf get_size b conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2 conv (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2 a1 * (a2 - a1) + b1 * (b2 - b1) a1 * (a2 - a1) a1 a2 - a1 a2 a1 b1 * (b2 - b1) b1 b2 - b1 b2 b1 2 ans.append(ans[-1]-conv) ans.append ans append ans[-1]-conv ans[-1] ans -1 conv print('\n'.join(map(str, ans[-2::-1]))) print '\n'.join(map(str, ans[-2::-1])) '\n'.join '\n' join map(str, ans[-2::-1]) map str ans[-2::-1] ans -2::-1 -2 -1 conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2 (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2 conv n, m = map(int, input().split()) map(int, input().split()) n b1 = uf.get_size(b) uf.get_size(b) b1 a1 = uf.get_size(a) uf.get_size(a) a1 b = map(int, input().split()) map(int, input().split()) b class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x] class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x] UnionFind uf = UnionFind(n) UnionFind(n) uf a2 = uf.get_size(a) uf.get_size(a) a2 m = map(int, input().split()) map(int, input().split()) m ans = [n * (n-1) // 2] [n * (n-1) // 2] ans bridges = [] [] bridges a, b = map(int, input().split()) map(int, input().split()) a b2 = uf.get_size(b) uf.get_size(b) b2
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())

bridges = []
for i in range(m):
    a, b = map(int, input().split())
    bridges.append((a-1, b-1))

uf = UnionFind(n)
ans = [n * (n-1) // 2]
for a, b in bridges[::-1]:
    a1 = uf.get_size(a)
    b1 = uf.get_size(b)
    uf.union(a, b)
    a2 = uf.get_size(a)
    b2 = uf.get_size(b)

    conv = (a1 * (a2 - a1) + b1 * (b2 - b1)) // 2
    ans.append(ans[-1]-conv)

print('\n'.join(map(str, ans[-2::-1])))
