class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)]
n, m = map(int, input().split())
x = [0]*m; x[m-1] = n*(n-1)//2; uf = UnionFind(n)
a = [0]*m; b = [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
for i in range(m-1, 0, -1):
    if uf.is_same(a[i], b[i]): x[i-1] = x[i]
    else:
        x[i-1] = x[i]-uf.group_size(a[i])*uf.group_size(b[i])
        uf.unite(a[i], b[i])
print(*x, sep="\n") class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)] UnionFind def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
     __init__ self.n = n self.n self n n i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.parent = [i for i in range(n)] self.parent self parent [i for i in range(n)] self.rank = [1]*n self.rank self rank [1]*n [1] 1 n self.size = [1]*n self.size self size [1]*n [1] 1 n self self n n def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
     find if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
     self.parent[x] == x self.parent[x] self.parent self parent x x return x x self.parent[x] = self.find(self.parent[x]) self.parent[x] self.parent self parent x self.find(self.parent[x]) self.find self find self.parent[x] self.parent self parent x return self.parent[x] self.parent[x] self.parent self parent x self self x x def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
     unite 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]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
     x != y x y if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                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.parent[x] = y self.parent[x] self.parent self parent x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x self.parent[y] = x self.parent[y] self.parent self parent y x self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y 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 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 group_size(self, x):
        return self.size[self.find(x)] group_size return self.size[self.find(x)] self.size[self.find(x)] self.size self size self.find(x) self.find self find x self self x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m x = [0]*m x [0]*m [0] 0 m x[m-1] = n*(n-1)//2 x[m-1] x m-1 m 1 n*(n-1)//2 n*(n-1) n n-1 n 1 2 uf = UnionFind(n) uf UnionFind(n) UnionFind n a = [0]*m a [0]*m [0] 0 m b = [0]*m b [0]*m [0] 0 m for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1 i range(m) range m a[i], b[i] = map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b[i] b i a[i] -= 1 a[i] a i 1 b[i] -= 1 b[i] b i 1 for i in range(m-1, 0, -1):
    if uf.is_same(a[i], b[i]): x[i-1] = x[i]
    else:
        x[i-1] = x[i]-uf.group_size(a[i])*uf.group_size(b[i])
        uf.unite(a[i], b[i]) i range(m-1, 0, -1) range m-1 m 1 0 -1 if uf.is_same(a[i], b[i]): x[i-1] = x[i]
    else:
        x[i-1] = x[i]-uf.group_size(a[i])*uf.group_size(b[i])
        uf.unite(a[i], b[i]) uf.is_same(a[i], b[i]) uf.is_same uf is_same a[i] a i b[i] b i x[i-1] = x[i]-uf.group_size(a[i])*uf.group_size(b[i]) x[i-1] x i-1 i 1 x[i]-uf.group_size(a[i])*uf.group_size(b[i]) x[i] x i uf.group_size(a[i])*uf.group_size(b[i]) uf.group_size(a[i]) uf.group_size uf group_size a[i] a i uf.group_size(b[i]) uf.group_size uf group_size b[i] b i uf.unite(a[i], b[i]) uf.unite uf unite a[i] a i b[i] b i print(*x, sep="\n") print *x x sep="\n" sep "\n" b = [0]*m [0]*m b a = [0]*m [0]*m a x = [0]*m [0]*m x m = map(int, input().split()) map(int, input().split()) m class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)] class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)] UnionFind n, m = map(int, input().split()) map(int, input().split()) n uf = UnionFind(n) UnionFind(n) uf
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)]
n, m = map(int, input().split())
x = [0]*m; x[m-1] = n*(n-1)//2; uf = UnionFind(n)
a = [0]*m; b = [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
for i in range(m-1, 0, -1):
    if uf.is_same(a[i], b[i]): x[i-1] = x[i]
    else:
        x[i-1] = x[i]-uf.group_size(a[i])*uf.group_size(b[i])
        uf.unite(a[i], b[i])
print(*x, sep="\n")