import sys

sys.setrecursionlimit(10**5)


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

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)]


n, m = map(int, input().split())
bridges = [tuple((int(i)-1 for i in input().split())) for _ in range(m)]
islands = UnionFind(n)
res = [n*(n-1)//2]
for a, b in bridges[:0:-1]:
    if islands.same(a, b):
        res.append(res[-1])
    else:
        res.append(res[-1] - islands.size(a) * islands.size(b))
        islands.unite(a, b)
print('\n'.join(map(str, res[::-1]))) import sys sys sys.setrecursionlimit(10**5) sys.setrecursionlimit sys setrecursionlimit 10**5 10 5 class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)] 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 root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

     root if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.root(self.parents[x]) self.parents[x] self.parents self parents x self.root(self.parents[x]) self.root self root 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 unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

     unite rx = self.root(x) rx self.root(x) self.root self root x ry = self.root(y) ry self.root(y) self.root self root y if rx == ry:
            return
         rx == ry rx ry return if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y rx, ry = ry, rx rx ry ry rx self.parents[rx] += self.parents[ry] self.parents[rx] self.parents self parents rx self.parents[ry] self.parents self parents ry self.parents[ry] = rx self.parents[ry] self.parents self parents ry rx self self x x y y def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

     same rx = self.root(x) rx self.root(x) self.root self root x ry = self.root(y) ry self.root(y) self.root self root y return rx == ry rx == ry rx ry self self x x y y def size(self, x):
        return -self.parents[self.root(x)] size return -self.parents[self.root(x)] -self.parents[self.root(x)] self.parents[self.root(x)] self.parents self parents self.root(x) self.root self root x self self x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m tuple((int(i)-1 for i in input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple((int(i)-1 for i in input().split())) tuple (int(i)-1 for i in input().split()) bridges = [tuple((int(i)-1 for i in input().split())) for _ in range(m)] bridges [tuple((int(i)-1 for i in input().split())) for _ in range(m)] islands = UnionFind(n) islands UnionFind(n) UnionFind n res = [n*(n-1)//2] res [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 for a, b in bridges[:0:-1]:
    if islands.same(a, b):
        res.append(res[-1])
    else:
        res.append(res[-1] - islands.size(a) * islands.size(b))
        islands.unite(a, b) a b bridges[:0:-1] bridges :0:-1 0 -1 if islands.same(a, b):
        res.append(res[-1])
    else:
        res.append(res[-1] - islands.size(a) * islands.size(b))
        islands.unite(a, b) islands.same(a, b) islands.same islands same a b res.append(res[-1]) res.append res append res[-1] res -1 res.append(res[-1] - islands.size(a) * islands.size(b)) res.append res append res[-1] - islands.size(a) * islands.size(b) res[-1] res -1 islands.size(a) * islands.size(b) islands.size(a) islands.size islands size a islands.size(b) islands.size islands size b islands.unite(a, b) islands.unite islands unite a b print('\n'.join(map(str, res[::-1]))) print '\n'.join(map(str, res[::-1])) '\n'.join '\n' join map(str, res[::-1]) map str res[::-1] res ::-1 -1 class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)] class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)] UnionFind m = map(int, input().split()) map(int, input().split()) m bridges = [tuple((int(i)-1 for i in input().split())) for _ in range(m)] [tuple((int(i)-1 for i in input().split())) for _ in range(m)] bridges res = [n*(n-1)//2] [n*(n-1)//2] res n, m = map(int, input().split()) map(int, input().split()) n islands = UnionFind(n) UnionFind(n) islands
import sys

sys.setrecursionlimit(10**5)


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

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.parents[x] > self.parents[y]:
            rx, ry = ry, rx
        self.parents[rx] += self.parents[ry]
        self.parents[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def size(self, x):
        return -self.parents[self.root(x)]


n, m = map(int, input().split())
bridges = [tuple((int(i)-1 for i in input().split())) for _ in range(m)]
islands = UnionFind(n)
res = [n*(n-1)//2]
for a, b in bridges[:0:-1]:
    if islands.same(a, b):
        res.append(res[-1])
    else:
        res.append(res[-1] - islands.size(a) * islands.size(b))
        islands.unite(a, b)
print('\n'.join(map(str, res[::-1])))
