class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y]

N, M = map(int, input().split())
ab = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
uf = UnionFind(N)

now = N*(N-1)//2
ans = [now]
for i in range(M-1):
    a = ab[M - i - 1][0]
    b = ab[M - i - 1][1]
    pa = uf.find(a)
    pb = uf.find(b)
    if pa != pb:
        now -= uf.size[pa] * uf.size[pb]
        uf.union(a, b)
    ans.append(now)
[print(a) for a in ans[::-1]] class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y] UnionFind def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

     __init__ self.parents = list(range(n)) self.parents self parents list(range(n)) list range(n) range n self.size = [1] * n self.size self size [1] * n [1] 1 n self self n n def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     find if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     self.parents[x] == x self.parents[x] self.parents self parents x x return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y] union 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.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y] x != y x y if self.size[x] < self.size[y]:
                x, y = y, x
             self.size[x] < self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y x, y = y, x x y y x self.parents[y] = x self.parents[y] self.parents self parents 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 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M list(map(lambda x: int(x)-1, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(lambda x: int(x)-1, input().split())) list map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split ab = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)] ab [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)] uf = UnionFind(N) uf UnionFind(N) UnionFind N now = N*(N-1)//2 now N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [now] ans [now] now for i in range(M-1):
    a = ab[M - i - 1][0]
    b = ab[M - i - 1][1]
    pa = uf.find(a)
    pb = uf.find(b)
    if pa != pb:
        now -= uf.size[pa] * uf.size[pb]
        uf.union(a, b)
    ans.append(now) i range(M-1) range M-1 M 1 a = ab[M - i - 1][0] a ab[M - i - 1][0] [M - i - 1] ab M - i - 1 M - i M i 1 0 b = ab[M - i - 1][1] b ab[M - i - 1][1] [M - i - 1] ab M - i - 1 M - i M i 1 1 pa = uf.find(a) pa uf.find(a) uf.find uf find a pb = uf.find(b) pb uf.find(b) uf.find uf find b if pa != pb:
        now -= uf.size[pa] * uf.size[pb]
        uf.union(a, b)
     pa != pb pa pb now -= uf.size[pa] * uf.size[pb] now uf.size[pa] * uf.size[pb] uf.size[pa] uf.size uf size pa uf.size[pb] uf.size uf size pb uf.union(a, b) uf.union uf union a b ans.append(now) ans.append ans append now print(a) for a in ans[::-1] for a in ans[::-1] a ans[::-1] ans ::-1 -1 for a in ans[::-1] print(a) print a [print(a) for a in ans[::-1]] uf = UnionFind(N) UnionFind(N) uf ab = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)] [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)] ab now = N*(N-1)//2 N*(N-1)//2 now ans = [now] [now] ans N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M b = ab[M - i - 1][1] ab[M - i - 1][1] b now -= uf.size[pa] * uf.size[pb] uf.size[pa] * uf.size[pb] now class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y] class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y] UnionFind a = ab[M - i - 1][0] ab[M - i - 1][0] a pa = uf.find(a) uf.find(a) pa pb = uf.find(b) uf.find(b) pb
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x, y = y, x
            self.parents[y] = x
            self.size[x] += self.size[y]

N, M = map(int, input().split())
ab = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
uf = UnionFind(N)

now = N*(N-1)//2
ans = [now]
for i in range(M-1):
    a = ab[M - i - 1][0]
    b = ab[M - i - 1][1]
    pa = uf.find(a)
    pb = uf.find(b)
    if pa != pb:
        now -= uf.size[pa] * uf.size[pb]
        uf.union(a, b)
    ans.append(now)
[print(a) for a in ans[::-1]]