class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)]

n,m = map(int,input().split())
brg = [[int(i)-1 for i in input().split()] for _ in range(m)]
cnt = n*(n-1)//2
ans = [0]*m
ds = DisjointSet(n)
for i in range(m)[::-1]:
    ans[i] = cnt
    a,b = brg[i]
    if not ds.same(a,b):
        cnt -= ds.size(a)*ds.size(b)
        ds.unite(a,b)
print("\n".join(map(str,ans))) class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)] DisjointSet def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

     __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.siz = [1]*n self.siz self siz [1]*n [1] 1 n self self n n def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

     root if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
         x != self.parent[x] x self.parent[x] self.parent self parent x self.parent[x] = self.root(self.parent[x]) self.parent[x] self.parent self parent x self.root(self.parent[x]) self.root self root 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 same(self,x,y): 
        return self.root(x) == self.root(y)

     same return self.root(x) == self.root(y) self.root(x) == self.root(y) self.root(x) self.root self root x self.root(y) self.root self root y self self x x y y def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

     unite x = self.root(x) x self.root(x) self.root self root x y = self.root(y) y self.root(y) self.root self root y if x == y: 
            return
         x == y x y return if self.siz[x] < self.siz[y]: 
            x,y = y,x
         self.siz[x] < self.siz[y] self.siz[x] self.siz self siz x self.siz[y] self.siz self siz y x,y = y,x x y y x self.parent[y] = x self.parent[y] self.parent self parent y x self.siz[x] += self.siz[y] self.siz[x] self.siz self siz x self.siz[y] self.siz self siz y self self x x y y def size(self,x):
        return self.siz[self.root(x)] size return self.siz[self.root(x)] self.siz[self.root(x)] self.siz self siz self.root(x) self.root self root x self self x x n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [int(i)-1 for i in input().split()] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [int(i)-1 for i in input().split()] brg = [[int(i)-1 for i in input().split()] for _ in range(m)] brg [[int(i)-1 for i in input().split()] for _ in range(m)] cnt = n*(n-1)//2 cnt n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans = [0]*m ans [0]*m [0] 0 m ds = DisjointSet(n) ds DisjointSet(n) DisjointSet n for i in range(m)[::-1]:
    ans[i] = cnt
    a,b = brg[i]
    if not ds.same(a,b):
        cnt -= ds.size(a)*ds.size(b)
        ds.unite(a,b) i range(m)[::-1] (m) range m ::-1 -1 ans[i] = cnt ans[i] ans i cnt a,b = brg[i] a brg[i] brg i b if not ds.same(a,b):
        cnt -= ds.size(a)*ds.size(b)
        ds.unite(a,b) not ds.same(a,b) ds.same(a,b) ds.same ds same a b cnt -= ds.size(a)*ds.size(b) cnt ds.size(a)*ds.size(b) ds.size(a) ds.size ds size a ds.size(b) ds.size ds size b ds.unite(a,b) ds.unite ds unite a b print("\n".join(map(str,ans))) print "\n".join(map(str,ans)) "\n".join "\n" join map(str,ans) map str ans cnt = n*(n-1)//2 n*(n-1)//2 cnt b = brg[i] brg[i] b ans = [0]*m [0]*m ans m = map(int,input().split()) map(int,input().split()) m cnt -= ds.size(a)*ds.size(b) ds.size(a)*ds.size(b) cnt class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)] class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)] DisjointSet ds = DisjointSet(n) DisjointSet(n) ds a,b = brg[i] brg[i] a n,m = map(int,input().split()) map(int,input().split()) n brg = [[int(i)-1 for i in input().split()] for _ in range(m)] [[int(i)-1 for i in input().split()] for _ in range(m)] brg
class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)]

n,m = map(int,input().split())
brg = [[int(i)-1 for i in input().split()] for _ in range(m)]
cnt = n*(n-1)//2
ans = [0]*m
ds = DisjointSet(n)
for i in range(m)[::-1]:
    ans[i] = cnt
    a,b = brg[i]
    if not ds.same(a,b):
        cnt -= ds.size(a)*ds.size(b)
        ds.unite(a,b)
print("\n".join(map(str,ans)))