class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(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())
int1 = lambda x: int(x) - 1
X = [tuple(map(int1, input().split())) for _ in range(M)]

uf = UnionFind(N)
lst = [0]
for a, b in reversed(X):
    if uf.issame(a, b):
        lst.append(lst[-1])
    else:
        lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b))
    uf.unite(a, b)

for i in range(M - 1, -1, -1):
    print(N * (N - 1) // 2 - lst[i]) class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(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.height = [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.height = [1] * n self.height self height [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

     x != y x y if self.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

     self.height[x] < self.height[y] self.height[x] self.height self height x self.height[y] self.height self height 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.height[x] == self.height[y]:
                    self.height[x] += 1

     self.height[x] == self.height[y] self.height[x] self.height self height x self.height[y] self.height self height y self.height[x] += 1 self.height[x] self.height self height x 1 self self x x y y def issame(self, x, y):
        return self.find(x) == self.find(y)

     issame 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 int1 = lambda x: int(x) - 1 int1 lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x tuple(map(int1, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(int1, input().split())) tuple map(int1, input().split()) map int1 input().split() ().split () input split X = [tuple(map(int1, input().split())) for _ in range(M)] X [tuple(map(int1, input().split())) for _ in range(M)] uf = UnionFind(N) uf UnionFind(N) UnionFind N lst = [0] lst [0] 0 for a, b in reversed(X):
    if uf.issame(a, b):
        lst.append(lst[-1])
    else:
        lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b))
    uf.unite(a, b) a b reversed(X) reversed X if uf.issame(a, b):
        lst.append(lst[-1])
    else:
        lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b))
     uf.issame(a, b) uf.issame uf issame a b lst.append(lst[-1]) lst.append lst append lst[-1] lst -1 lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b)) lst.append lst append lst[-1] + uf.group_size(a) * uf.group_size(b) lst[-1] lst -1 uf.group_size(a) * uf.group_size(b) uf.group_size(a) uf.group_size uf group_size a uf.group_size(b) uf.group_size uf group_size b uf.unite(a, b) uf.unite uf unite a b for i in range(M - 1, -1, -1):
    print(N * (N - 1) // 2 - lst[i]) i range(M - 1, -1, -1) range M - 1 M 1 -1 -1 print(N * (N - 1) // 2 - lst[i]) print N * (N - 1) // 2 - lst[i] N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 lst[i] lst i class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(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.height = [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

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

    def group_size(self, x):
        return self.size[self.find(x)] UnionFind int1 = lambda x: int(x) - 1 lambda x: int(x) - 1 int1 X = [tuple(map(int1, input().split())) for _ in range(M)] [tuple(map(int1, input().split())) for _ in range(M)] X uf = UnionFind(N) UnionFind(N) uf N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M lst = [0] [0] lst
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [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.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(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())
int1 = lambda x: int(x) - 1
X = [tuple(map(int1, input().split())) for _ in range(M)]

uf = UnionFind(N)
lst = [0]
for a, b in reversed(X):
    if uf.issame(a, b):
        lst.append(lst[-1])
    else:
        lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b))
    uf.unite(a, b)

for i in range(M - 1, -1, -1):
    print(N * (N - 1) // 2 - lst[i])
