N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
t = N*(N-1)//2
ans = [t]
for a,b in reversed(AB):
    a,b = a-1,b-1
    if uf.is_same(a,b):
        ans.append(t)
    else:
        t -= uf.size(a) * uf.size(b)
        ans.append(t)
        uf.unite(a,b)
print(*ans[::-1][1:], sep='\n') N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M tuple(map(int,input().split())) for i in range(M) for i in range(M) i range(M) range M for i in range(M) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split AB = [tuple(map(int,input().split())) for i in range(M)] AB [tuple(map(int,input().split())) for i in range(M)] class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)] UnionFind def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
     __init__ i for i in range(N) for i in range(N) i range(N) range N for i in range(N) i self.parent = [i for i in range(N)] self.parent self parent [i for i in range(N)] self._size = [1] * N self._size self _size [1] * N [1] 1 N self.count = 0 self.count self count 0 self self N N def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
     root if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
     self.parent[a] == a self.parent[a] self.parent self parent a a return a a self.parent[a] = self.root(self.parent[a]) self.parent[a] self.parent self parent a self.root(self.parent[a]) self.root self root self.parent[a] self.parent self parent a return self.parent[a] self.parent[a] self.parent self parent a self self a a def is_same(self,a,b):
        return self.root(a) == self.root(b)
     is_same return self.root(a) == self.root(b) self.root(a) == self.root(b) self.root(a) self.root self root a self.root(b) self.root self root b self self a a b b def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
     unite ra = self.root(a) ra self.root(a) self.root self root a rb = self.root(b) rb self.root(b) self.root self root b if ra == rb: return
         ra == rb ra rb if self._size[ra] < self._size[rb]: ra,rb = rb,ra
         self._size[ra] < self._size[rb] self._size[ra] self._size self _size ra self._size[rb] self._size self _size rb self._size[ra] += self._size[rb] self._size[ra] self._size self _size ra self._size[rb] self._size self _size rb self.parent[rb] = ra self.parent[rb] self.parent self parent rb ra self.count += 1 self.count self count 1 self self a a b b def size(self,a):
        return self._size[self.root(a)] size return self._size[self.root(a)] self._size[self.root(a)] self._size self _size self.root(a) self.root self root a self self a a uf = UnionFind(N) uf UnionFind(N) UnionFind N t = N*(N-1)//2 t N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [t] ans [t] t for a,b in reversed(AB):
    a,b = a-1,b-1
    if uf.is_same(a,b):
        ans.append(t)
    else:
        t -= uf.size(a) * uf.size(b)
        ans.append(t)
        uf.unite(a,b) a b reversed(AB) reversed AB a,b = a-1,b-1 a a-1 a 1 b b-1 b 1 if uf.is_same(a,b):
        ans.append(t)
    else:
        t -= uf.size(a) * uf.size(b)
        ans.append(t)
        uf.unite(a,b) uf.is_same(a,b) uf.is_same uf is_same a b ans.append(t) ans.append ans append t t -= uf.size(a) * uf.size(b) t uf.size(a) * uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b ans.append(t) ans.append ans append t uf.unite(a,b) uf.unite uf unite a b print(*ans[::-1][1:], sep='\n') print *ans[::-1][1:] ans[::-1][1:] [::-1] ans ::-1 -1 1: 1 sep='\n' sep '\n' M = map(int,input().split()) map(int,input().split()) M b = a-1,b-1 b-1 b N,M = map(int,input().split()) map(int,input().split()) N a,b = a-1,b-1 a-1 a ans = [t] [t] ans class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)] class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)] UnionFind AB = [tuple(map(int,input().split())) for i in range(M)] [tuple(map(int,input().split())) for i in range(M)] AB uf = UnionFind(N) UnionFind(N) uf t = N*(N-1)//2 N*(N-1)//2 t t -= uf.size(a) * uf.size(b) uf.size(a) * uf.size(b) t
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
t = N*(N-1)//2
ans = [t]
for a,b in reversed(AB):
    a,b = a-1,b-1
    if uf.is_same(a,b):
        ans.append(t)
    else:
        t -= uf.size(a) * uf.size(b)
        ans.append(t)
        uf.unite(a,b)
print(*ans[::-1][1:], sep='\n')