class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

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

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

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


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

ans = []
inconv = n * (n-1) // 2
uf_tree = UnionFind(n)

for a, b in ab[::-1]:
    a -= 1; b -= 1;
    ans.append(inconv)
    if not uf_tree.same(a, b):
        x = uf_tree.size(a)
        y = uf_tree.size(b)
        uf_tree.unite(a, b)
        inconv -= x*y

print(*ans[::-1], sep="\n") class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

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

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

    def size(self, x):
        return -self.parent[self.root(x)] UnionFind def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

     __init__ -1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) -1 self.parent = [ -1 for _ in range(n) ] self.parent self parent [ -1 for _ in range(n) ] self._size = n self._size self _size n self self n n def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

     unite x, y = self.root(x), self.root(y) x self.root(x) self.root self root x y self.root(y) self.root self root y if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

     x != y x y if self.parent[y] < self.parent[x]:
                x, y = y, x
             self.parent[y] < self.parent[x] self.parent[y] self.parent self parent y self.parent[x] self.parent self parent x x, y = y, x x y y x self.parent[x] += self.parent[y] self.parent[x] self.parent self parent x self.parent[y] self.parent self parent y self.parent[y] = x self.parent[y] self.parent self parent y x self._size -= 1 self._size self _size 1 self self x x y y def same(self, x, y):
        return self.root(x) == self.root(y)

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

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

     self.parent[x] < 0 self.parent[x] self.parent self parent x 0 return x x self.parent[x] = self.root(self.parent[x]) self.parent[x] self.parent self parent x self.root(self.parent[x]) self.root self root self.parent[x] self.parent self parent x return self.root(self.parent[x]) self.root(self.parent[x]) self.root self root self.parent[x] self.parent self parent x self self x x def size(self, x):
        return -self.parent[self.root(x)] size return -self.parent[self.root(x)] -self.parent[self.root(x)] self.parent[self.root(x)] self.parent self parent 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 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 ab = [ map(int, input().split()) for _ in range(m) ] ab [ map(int, input().split()) for _ in range(m) ] ans = [] ans [] inconv = n * (n-1) // 2 inconv n * (n-1) // 2 n * (n-1) n n-1 n 1 2 uf_tree = UnionFind(n) uf_tree UnionFind(n) UnionFind n for a, b in ab[::-1]:
    a -= 1; b -= 1;
    ans.append(inconv)
    if not uf_tree.same(a, b):
        x = uf_tree.size(a)
        y = uf_tree.size(b)
        uf_tree.unite(a, b)
        inconv -= x*y a b ab[::-1] ab ::-1 -1 a -= 1 a 1 b -= 1 b 1 ans.append(inconv) ans.append ans append inconv if not uf_tree.same(a, b):
        x = uf_tree.size(a)
        y = uf_tree.size(b)
        uf_tree.unite(a, b)
        inconv -= x*y not uf_tree.same(a, b) uf_tree.same(a, b) uf_tree.same uf_tree same a b x = uf_tree.size(a) x uf_tree.size(a) uf_tree.size uf_tree size a y = uf_tree.size(b) y uf_tree.size(b) uf_tree.size uf_tree size b uf_tree.unite(a, b) uf_tree.unite uf_tree unite a b inconv -= x*y inconv x*y x y print(*ans[::-1], sep="\n") print *ans[::-1] ans[::-1] ans ::-1 -1 sep="\n" sep "\n" m = map(int, input().split()) map(int, input().split()) m class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

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

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

    def size(self, x):
        return -self.parent[self.root(x)] class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

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

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

    def size(self, x):
        return -self.parent[self.root(x)] UnionFind inconv = n * (n-1) // 2 n * (n-1) // 2 inconv uf_tree = UnionFind(n) UnionFind(n) uf_tree a -= 1 1 a b -= 1 1 b y = uf_tree.size(b) uf_tree.size(b) y ans = [] [] ans x = uf_tree.size(a) uf_tree.size(a) x inconv -= x*y x*y inconv n, m = map(int, input().split()) map(int, input().split()) n ab = [ map(int, input().split()) for _ in range(m) ] [ map(int, input().split()) for _ in range(m) ] ab
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

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

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

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


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

ans = []
inconv = n * (n-1) // 2
uf_tree = UnionFind(n)

for a, b in ab[::-1]:
    a -= 1; b -= 1;
    ans.append(inconv)
    if not uf_tree.same(a, b):
        x = uf_tree.size(a)
        y = uf_tree.size(b)
        uf_tree.unite(a, b)
        inconv -= x*y

print(*ans[::-1], sep="\n")