from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**8)

class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island

N,M = map(int, input().split())
A = [0]*M; B = [0]*M
for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split())

uf = Unionfind(N)
inconvenience = N * (N-1) // 2
inconvenience_list = [0]*M
inconvenience_list[M-1] = inconvenience
for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience
for i in range(M):
    print(inconvenience_list[i]) from sys import stdin, setrecursionlimit input = stdin.readline input stdin.readline stdin readline setrecursionlimit(10**8) setrecursionlimit 10**8 10 8 class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island Unionfind def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
     __init__ self.n = n self.n self n n self.parent = [-1]*n self.parent self parent [-1]*n [-1] -1 n self self n n def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
     find if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
     self.parent[x] < 0 self.parent[x] self.parent self parent x 0 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 union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island 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.parent[x] < self.parent[y]:
            x,y = y,x
        
         self.parent[x] < self.parent[y] self.parent[x] self.parent self parent x self.parent[y] self.parent self parent y x,y = y,x x y y x total_unite_island = self.parent[x] * self.parent[y] total_unite_island self.parent[x] * self.parent[y] self.parent[x] self.parent self parent x self.parent[y] self.parent self parent y self.parent[x] += self.parent[y] self.parent[x] self.parent self parent x self.parent[y] self.parent self parent y self.parent[y] = x self.parent[y] self.parent self parent y x return total_unite_island total_unite_island 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 A = [0]*M A [0]*M [0] 0 M B = [0]*M B [0]*M [0] 0 M for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split()) i range(M) range M A[i], B[i] = map(lambda x: int(x) - 1, input().split()) A[i] A i 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 B[i] B i uf = Unionfind(N) uf Unionfind(N) Unionfind N inconvenience = N * (N-1) // 2 inconvenience N * (N-1) // 2 N * (N-1) N N-1 N 1 2 inconvenience_list = [0]*M inconvenience_list [0]*M [0] 0 M inconvenience_list[M-1] = inconvenience inconvenience_list[M-1] inconvenience_list M-1 M 1 inconvenience for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience i range(M-1,0,-1) range M-1 M 1 0 -1 inconvenience -= uf.union(A[i],B[i]) inconvenience uf.union(A[i],B[i]) uf.union uf union A[i] A i B[i] B i inconvenience_list[i-1] = inconvenience inconvenience_list[i-1] inconvenience_list i-1 i 1 inconvenience for i in range(M):
    print(inconvenience_list[i]) i range(M) range M print(inconvenience_list[i]) print inconvenience_list[i] inconvenience_list i inconvenience_list = [0]*M [0]*M inconvenience_list inconvenience -= uf.union(A[i],B[i]) uf.union(A[i],B[i]) inconvenience M = map(int, input().split()) map(int, input().split()) M uf = Unionfind(N) Unionfind(N) uf inconvenience = N * (N-1) // 2 N * (N-1) // 2 inconvenience class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island Unionfind A = [0]*M [0]*M A input = stdin.readline stdin.readline input N,M = map(int, input().split()) map(int, input().split()) N B = [0]*M [0]*M B
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**8)

class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island

N,M = map(int, input().split())
A = [0]*M; B = [0]*M
for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split())

uf = Unionfind(N)
inconvenience = N * (N-1) // 2
inconvenience_list = [0]*M
inconvenience_list[M-1] = inconvenience
for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience
for i in range(M):
    print(inconvenience_list[i])