
class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        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):
        return self.size[self.find(x)]


N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

tree = UnionFind(N + 1)
res = [N * (N - 1) // 2]
for a, b in reversed(X[1:]):
    if not tree.is_same(a, b):
        num0 = tree.get_size(a)
        num1 = tree.get_size(b)
        res.append(res[-1] - num0 * num1)
    else:
        res.append(res[-1])
    tree.unite(a, b)

print(*res[::-1], sep="\n") class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        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):
        return self.size[self.find(x)] UnionFind def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * n

     __init__ self.par = list(range(n)) self.par self par list(range(n)) list range(n) range n self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self.size = [1] * n self.size self size [1] * n [1] 1 n self self n 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]

     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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        self.par[y] = x
        self.size[x] += self.size[y]

     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:
            return

         x == y x y return if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif 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 self.rank[x] += 1 self.rank[x] self.rank self rank x 1 elif 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 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):
        return self.size[self.find(x)] get_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 list(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split X = [list(map(int, input().split())) for _ in range(M)] X [list(map(int, input().split())) for _ in range(M)] tree = UnionFind(N + 1) tree UnionFind(N + 1) UnionFind N + 1 N 1 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 reversed(X[1:]):
    if not tree.is_same(a, b):
        num0 = tree.get_size(a)
        num1 = tree.get_size(b)
        res.append(res[-1] - num0 * num1)
    else:
        res.append(res[-1])
    tree.unite(a, b) a b reversed(X[1:]) reversed X[1:] X 1: 1 if not tree.is_same(a, b):
        num0 = tree.get_size(a)
        num1 = tree.get_size(b)
        res.append(res[-1] - num0 * num1)
    else:
        res.append(res[-1])
     not tree.is_same(a, b) tree.is_same(a, b) tree.is_same tree is_same a b num0 = tree.get_size(a) num0 tree.get_size(a) tree.get_size tree get_size a num1 = tree.get_size(b) num1 tree.get_size(b) tree.get_size tree get_size b res.append(res[-1] - num0 * num1) res.append res append res[-1] - num0 * num1 res[-1] res -1 num0 * num1 num0 num1 res.append(res[-1]) res.append res append res[-1] res -1 tree.unite(a, b) tree.unite tree unite a b print(*res[::-1], sep="\n") print *res[::-1] res[::-1] res ::-1 -1 sep="\n" sep "\n" class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        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):
        return self.size[self.find(x)] class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        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):
        return self.size[self.find(x)] UnionFind N, M = map(int, input().split()) map(int, input().split()) N res = [N * (N - 1) // 2] [N * (N - 1) // 2] res num1 = tree.get_size(b) tree.get_size(b) num1 num0 = tree.get_size(a) tree.get_size(a) num0 X = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] X tree = UnionFind(N + 1) UnionFind(N + 1) tree M = map(int, input().split()) map(int, input().split()) M

class UnionFind:
    def __init__(self, n):
        self.par = list(range(n))
        self.rank = [0] * n
        self.size = [1] * 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        elif self.rank[x] < self.rank[y]:
            x, y = y, x

        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):
        return self.size[self.find(x)]


N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

tree = UnionFind(N + 1)
res = [N * (N - 1) // 2]
for a, b in reversed(X[1:]):
    if not tree.is_same(a, b):
        num0 = tree.get_size(a)
        num1 = tree.get_size(b)
        res.append(res[-1] - num0 * num1)
    else:
        res.append(res[-1])
    tree.unite(a, b)

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