# Decayed Bridges
from collections import deque

class UnionFind():
    def __init__(self, x):
        self.parent = [-1] * x

    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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

    def Size(self, x):
        return self.parent[self.Find(x)]*-1

N, M = map(int, input().split())
AB = deque()
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append([a, b])

uf = UnionFind(N)

ans = deque()
tmp = N*(N-1)//2
ans.append(tmp)
for i in range(M-1):
    a, b = AB.pop()
    if uf.isSameGroup(a, b):
        ans.append(tmp)
    else:
        tmp -= uf.Size(a) * uf.Size(b)
        ans.append(tmp)
        uf.Union(a, b)

for i in range(M):
    print(ans.pop()) from collections import deque class UnionFind():
    def __init__(self, x):
        self.parent = [-1] * x

    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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

    def Size(self, x):
        return self.parent[self.Find(x)]*-1 UnionFind def __init__(self, x):
        self.parent = [-1] * x

     __init__ self.parent = [-1] * x self.parent self parent [-1] * x [-1] -1 x self self x x 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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

     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 False
         x==y x y return False False if x>y:
            x, y = y, x
         x>y x y x, y = y, x 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 self.parent[y] = x self.parent[y] self.parent self parent y x return True True self self x x y y def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

     isSameGroup 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 Size(self, x):
        return self.parent[self.Find(x)]*-1 Size return self.parent[self.Find(x)]*-1 self.parent[self.Find(x)]*-1 self.parent[self.Find(x)] self.parent self parent self.Find(x) self.Find self Find x -1 self self x x N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M AB = deque() AB deque() deque for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append([a, b]) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b a -= 1 a 1 b -= 1 b 1 AB.append([a, b]) AB.append AB append [a, b] a b uf = UnionFind(N) uf UnionFind(N) UnionFind N ans = deque() ans deque() deque tmp = N*(N-1)//2 tmp N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans.append(tmp) ans.append ans append tmp for i in range(M-1):
    a, b = AB.pop()
    if uf.isSameGroup(a, b):
        ans.append(tmp)
    else:
        tmp -= uf.Size(a) * uf.Size(b)
        ans.append(tmp)
        uf.Union(a, b) i range(M-1) range M-1 M 1 a, b = AB.pop() a AB.pop() AB.pop AB pop b if uf.isSameGroup(a, b):
        ans.append(tmp)
    else:
        tmp -= uf.Size(a) * uf.Size(b)
        ans.append(tmp)
        uf.Union(a, b) uf.isSameGroup(a, b) uf.isSameGroup uf isSameGroup a b ans.append(tmp) ans.append ans append tmp tmp -= uf.Size(a) * uf.Size(b) tmp uf.Size(a) * uf.Size(b) uf.Size(a) uf.Size uf Size a uf.Size(b) uf.Size uf Size b ans.append(tmp) ans.append ans append tmp uf.Union(a, b) uf.Union uf Union a b for i in range(M):
    print(ans.pop()) i range(M) range M print(ans.pop()) print ans.pop() ans.pop ans pop a, b = AB.pop() AB.pop() a AB = deque() deque() AB b = map(int, input().split()) map(int, input().split()) b ans = deque() deque() ans tmp = N*(N-1)//2 N*(N-1)//2 tmp b -= 1 1 b a, b = map(int, input().split()) map(int, input().split()) a M = map(int, input().split()) map(int, input().split()) M a -= 1 1 a class UnionFind():
    def __init__(self, x):
        self.parent = [-1] * x

    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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

    def Size(self, x):
        return self.parent[self.Find(x)]*-1 class UnionFind():
    def __init__(self, x):
        self.parent = [-1] * x

    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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

    def Size(self, x):
        return self.parent[self.Find(x)]*-1 UnionFind b = AB.pop() AB.pop() b tmp -= uf.Size(a) * uf.Size(b) uf.Size(a) * uf.Size(b) tmp N, M = map(int, input().split()) map(int, input().split()) N uf = UnionFind(N) UnionFind(N) uf
# Decayed Bridges
from collections import deque

class UnionFind():
    def __init__(self, x):
        self.parent = [-1] * x

    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 False
        if x>y:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

    def isSameGroup(self, x, y):
        return self.Find(x)==self.Find(y)

    def Size(self, x):
        return self.parent[self.Find(x)]*-1

N, M = map(int, input().split())
AB = deque()
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append([a, b])

uf = UnionFind(N)

ans = deque()
tmp = N*(N-1)//2
ans.append(tmp)
for i in range(M-1):
    a, b = AB.pop()
    if uf.isSameGroup(a, b):
        ans.append(tmp)
    else:
        tmp -= uf.Size(a) * uf.Size(b)
        ans.append(tmp)
        uf.Union(a, b)

for i in range(M):
    print(ans.pop())
