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