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

ab.reverse()
cnt = [0] * N
lst = [0]*N

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:
            return self.find(self.parents[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
    def size(self, x):
        return -self.parents[self.find(x)]

uf = UnionFind(N)
cnt = N * (N - 1) // 2
ans = [cnt]
for a, b in ab:
    a -= 1
    b -= 1
    if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
    ans.append(cnt)
ans.reverse()
print(*ans[1:], sep='\n') 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 ab = [list(map(int, input().split())) for _ in range(M)] ab [list(map(int, input().split())) for _ in range(M)] ab.reverse() ab.reverse ab reverse cnt = [0] * N cnt [0] * N [0] 0 N lst = [0]*N lst [0]*N [0] 0 N 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:
            return self.find(self.parents[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
    def size(self, x):
        return -self.parents[self.find(x)] 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:
            return self.find(self.parents[x])
     find if self.parents[x] < 0:
            return x
        else:
            return self.find(self.parents[x])
     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x return self.find(self.parents[x]) self.find(self.parents[x]) self.find self find 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
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
     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
         x == y x y 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 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 self self x x y y def size(self, x):
        return -self.parents[self.find(x)] size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x uf = UnionFind(N) uf UnionFind(N) UnionFind N cnt = N * (N - 1) // 2 cnt N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 ans = [cnt] ans [cnt] cnt for a, b in ab:
    a -= 1
    b -= 1
    if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
    ans.append(cnt) a b ab a -= 1 a 1 b -= 1 b 1 if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
     uf.find(a) != uf.find(b) uf.find(a) uf.find uf find a uf.find(b) uf.find uf find b cnt -= uf.size(a) * uf.size(b) cnt uf.size(a) * uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b ans.append(cnt) ans.append ans append cnt ans.reverse() ans.reverse ans reverse print(*ans[1:], sep='\n') print *ans[1:] ans[1:] ans 1: 1 sep='\n' sep '\n' a -= 1 1 a cnt = [0] * N [0] * N cnt uf = UnionFind(N) UnionFind(N) uf M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N cnt -= uf.size(a) * uf.size(b) uf.size(a) * uf.size(b) cnt cnt = N * (N - 1) // 2 N * (N - 1) // 2 cnt ab = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] ab ans = [cnt] [cnt] ans b -= 1 1 b lst = [0]*N [0]*N lst 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:
            return self.find(self.parents[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
    def size(self, x):
        return -self.parents[self.find(x)] 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:
            return self.find(self.parents[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
    def size(self, x):
        return -self.parents[self.find(x)] UnionFind
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.reverse()
cnt = [0] * N
lst = [0]*N

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:
            return self.find(self.parents[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y: return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
     
    def size(self, x):
        return -self.parents[self.find(x)]

uf = UnionFind(N)
cnt = N * (N - 1) // 2
ans = [cnt]
for a, b in ab:
    a -= 1
    b -= 1
    if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
    ans.append(cnt)
ans.reverse()
print(*ans[1:], sep='\n')