import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split())
    AB = tuple(tuple(map(int, input().split())) for _ in range(M))
    score = N * (N - 1) // 2

    ans = [score]
    uf = UF_tree(N)
    for a, b in AB[::-1]:
        if uf.isSame(a, b):
            ans.append(score)
            continue
        x = uf.getNodeLen(a)
        y = uf.getNodeLen(b)
        uf.unite(a, b)
        score -= x * y
        ans.append(score)
    ans.reverse()
    print(*ans[1:], sep="\n") import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)] UF_tree def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

     __init__ self.root = [-1] * (n + 1) self.root self root [-1] * (n + 1) [-1] -1 n + 1 n 1 self.rank = [0] * (n + 1) self.rank self rank [0] * (n + 1) [0] 0 n + 1 n 1 self self n n def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

     self.root[x] < 0 self.root[x] self.root self root x 0 return x x self.root[x] = self.find(self.root[x]) self.root[x] self.root self root x self.find(self.root[x]) self.find self find self.root[x] self.root self root x return self.root[x] self.root[x] self.root self root x self self x x 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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            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:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

     x == y x y return elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
         self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.root[y] += self.root[x] self.root[y] self.root self root y self.root[x] self.root self root x self.root[x] = y self.root[x] self.root self root x y self.root[x] += self.root[y] self.root[x] self.root self root x self.root[y] self.root self root y self.root[y] = x self.root[y] self.root self root y x 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 getNodeLen(self, x):
        return -self.root[self.find(x)] getNodeLen return -self.root[self.find(x)] -self.root[self.find(x)] self.root[self.find(x)] self.root self root self.find(x) self.find self find x self self x x if __name__ == "__main__":
    N, M = map(int, input().split())
    AB = tuple(tuple(map(int, input().split())) for _ in range(M))
    score = N * (N - 1) // 2

    ans = [score]
    uf = UF_tree(N)
    for a, b in AB[::-1]:
        if uf.isSame(a, b):
            ans.append(score)
            continue
        x = uf.getNodeLen(a)
        y = uf.getNodeLen(b)
        uf.unite(a, b)
        score -= x * y
        ans.append(score)
    ans.reverse()
    print(*ans[1:], sep="\n") __name__ == "__main__" __name__ "__main__" N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M AB = tuple(tuple(map(int, input().split())) for _ in range(M)) AB tuple(tuple(map(int, input().split())) for _ in range(M)) tuple tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split score = N * (N - 1) // 2 score N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 ans = [score] ans [score] score uf = UF_tree(N) uf UF_tree(N) UF_tree N for a, b in AB[::-1]:
        if uf.isSame(a, b):
            ans.append(score)
            continue
        x = uf.getNodeLen(a)
        y = uf.getNodeLen(b)
        uf.unite(a, b)
        score -= x * y
        ans.append(score)
     a b AB[::-1] AB ::-1 -1 if uf.isSame(a, b):
            ans.append(score)
            continue
         uf.isSame(a, b) uf.isSame uf isSame a b ans.append(score) ans.append ans append score continue x = uf.getNodeLen(a) x uf.getNodeLen(a) uf.getNodeLen uf getNodeLen a y = uf.getNodeLen(b) y uf.getNodeLen(b) uf.getNodeLen uf getNodeLen b uf.unite(a, b) uf.unite uf unite a b score -= x * y score x * y x y ans.append(score) ans.append ans append score ans.reverse() ans.reverse ans reverse print(*ans[1:], sep="\n") print *ans[1:] ans[1:] ans 1: 1 sep="\n" sep "\n" class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)] class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)] UF_tree ans = [score] [score] ans x = uf.getNodeLen(a) uf.getNodeLen(a) x input = sys.stdin.buffer.readline sys.stdin.buffer.readline input uf = UF_tree(N) UF_tree(N) uf N, M = map(int, input().split()) map(int, input().split()) N y = uf.getNodeLen(b) uf.getNodeLen(b) y score -= x * y x * y score AB = tuple(tuple(map(int, input().split())) for _ in range(M)) tuple(tuple(map(int, input().split())) for _ in range(M)) AB M = map(int, input().split()) map(int, input().split()) M score = N * (N - 1) // 2 N * (N - 1) // 2 score
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class UF_tree:
    def __init__(self, n):
        self.root = [-1] * (n + 1)  # -1ならそのノードが根,で絶対値が木の要素数
        self.rank = [0] * (n + 1)

    def find(self, x):  # xの根となる要素番号を返す
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.root[y] += self.root[x]
            self.root[x] = y
        else:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getNodeLen(self, x):
        return -self.root[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split())
    AB = tuple(tuple(map(int, input().split())) for _ in range(M))
    score = N * (N - 1) // 2

    ans = [score]
    uf = UF_tree(N)
    for a, b in AB[::-1]:
        if uf.isSame(a, b):
            ans.append(score)
            continue
        x = uf.getNodeLen(a)
        y = uf.getNodeLen(b)
        uf.unite(a, b)
        score -= x * y
        ans.append(score)
    ans.reverse()
    print(*ans[1:], sep="\n")