class UnionFindWithSize(object):
    """UnionFindTree based on union by size + path compression.
    """
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)]

if __name__ == "__main__":
    N, M = map(int,input().split())
    edges = []
    for _ in range(M):
        edges.append(tuple(map(lambda x:int(x)-1,input().split())))
    uf = UnionFindWithSize(N)
    anss = []
    cnt = N*(N-1)//2
    for i in range(M-1, -1, -1):
        anss.append(cnt)
        a,b = edges[i]
        if not uf.same(a,b):
            cnt -= uf.sizeofset(a)*uf.sizeofset(b)
            uf.unite(a,b)
    for x in reversed(anss):
        print(x) class UnionFindWithSize(object):
    """UnionFindTree based on union by size + path compression.
    """
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)] UnionFindWithSize """UnionFindTree based on union by size + path compression.
    """ def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

     __init__ i for i in range(size) for i in range(size) i range(size) range size for i in range(size) i self.parent = [i for i in range(size)] self.parent self parent [i for i in range(size)] self.size = [1]*size self.size self size [1]*size [1] 1 size self self size size def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
     find if self.parent[x] == x:
            return x
        # path compression
         self.parent[x] == x self.parent[x] self.parent self parent x x 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 unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
     unite x, y = self.find(x), self.find(y) x self.find(x) self.find self find x y self.find(y) self.find self find y if x == y:
            return
        # union by size
         x == y x y return if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[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.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x self.parent[x] = y self.parent[x] self.parent self parent x y self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self.parent[y] = x self.parent[y] self.parent self parent y x self self x x y y def same(self, x, y):
        return self.find(x) == self.find(y)
    
     same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def sizeofset(self, x):
        return self.size[self.find(x)] sizeofset return self.size[self.find(x)] self.size[self.find(x)] self.size self size self.find(x) self.find self find x self self x x object if __name__ == "__main__":
    N, M = map(int,input().split())
    edges = []
    for _ in range(M):
        edges.append(tuple(map(lambda x:int(x)-1,input().split())))
    uf = UnionFindWithSize(N)
    anss = []
    cnt = N*(N-1)//2
    for i in range(M-1, -1, -1):
        anss.append(cnt)
        a,b = edges[i]
        if not uf.same(a,b):
            cnt -= uf.sizeofset(a)*uf.sizeofset(b)
            uf.unite(a,b)
    for x in reversed(anss):
        print(x) __name__ == "__main__" __name__ "__main__" N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M edges = [] edges [] for _ in range(M):
        edges.append(tuple(map(lambda x:int(x)-1,input().split())))
     _ range(M) range M edges.append(tuple(map(lambda x:int(x)-1,input().split()))) edges.append edges append tuple(map(lambda x:int(x)-1,input().split())) tuple 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 uf = UnionFindWithSize(N) uf UnionFindWithSize(N) UnionFindWithSize N anss = [] anss [] cnt = N*(N-1)//2 cnt N*(N-1)//2 N*(N-1) N N-1 N 1 2 for i in range(M-1, -1, -1):
        anss.append(cnt)
        a,b = edges[i]
        if not uf.same(a,b):
            cnt -= uf.sizeofset(a)*uf.sizeofset(b)
            uf.unite(a,b)
     i range(M-1, -1, -1) range M-1 M 1 -1 -1 anss.append(cnt) anss.append anss append cnt a,b = edges[i] a edges[i] edges i b if not uf.same(a,b):
            cnt -= uf.sizeofset(a)*uf.sizeofset(b)
            uf.unite(a,b)
     not uf.same(a,b) uf.same(a,b) uf.same uf same a b cnt -= uf.sizeofset(a)*uf.sizeofset(b) cnt uf.sizeofset(a)*uf.sizeofset(b) uf.sizeofset(a) uf.sizeofset uf sizeofset a uf.sizeofset(b) uf.sizeofset uf sizeofset b uf.unite(a,b) uf.unite uf unite a b for x in reversed(anss):
        print(x) x reversed(anss) reversed anss print(x) print x M = map(int,input().split()) map(int,input().split()) M a,b = edges[i] edges[i] a cnt -= uf.sizeofset(a)*uf.sizeofset(b) uf.sizeofset(a)*uf.sizeofset(b) cnt class UnionFindWithSize(object):
    """UnionFindTree based on union by size + path compression.
    """
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)] class UnionFindWithSize(object):
    """UnionFindTree based on union by size + path compression.
    """
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)] UnionFindWithSize N, M = map(int,input().split()) map(int,input().split()) N uf = UnionFindWithSize(N) UnionFindWithSize(N) uf cnt = N*(N-1)//2 N*(N-1)//2 cnt b = edges[i] edges[i] b edges = [] [] edges anss = [] [] anss
class UnionFindWithSize(object):
    """UnionFindTree based on union by size + path compression.
    """
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.size = [1]*size

    def find(self, x):
        if self.parent[x] == x:
            return x
        # path compression
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
    
    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        # union by size
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parent[x] = y
        else:
            self.size[x] += self.size[y]
            self.parent[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def sizeofset(self, x):
        return self.size[self.find(x)]

if __name__ == "__main__":
    N, M = map(int,input().split())
    edges = []
    for _ in range(M):
        edges.append(tuple(map(lambda x:int(x)-1,input().split())))
    uf = UnionFindWithSize(N)
    anss = []
    cnt = N*(N-1)//2
    for i in range(M-1, -1, -1):
        anss.append(cnt)
        a,b = edges[i]
        if not uf.same(a,b):
            cnt -= uf.sizeofset(a)*uf.sizeofset(b)
            uf.unite(a,b)
    for x in reversed(anss):
        print(x)