# union by sixe
class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

N, M = map(int, input().split())
ds = DisjointSet(N+1) 
stack = []
ans = [N*(N-1)//2]
for m in range(M):
    a, b = map(int, input().split())
    stack += [(a, b)]
for m in range(M):
    a, b = stack.pop()
    if ds.same(a, b):
        ans += [ans[-1]]
    else:
        ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]]
        ds.unite(a, b)
ans = ans[::-1]
for i in range(1, M+1):
    print(ans[i]) class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x] DisjointSet def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
     __init__ 0 for i in range(size) for i in range(size) i range(size) range size for i in range(size) 0 self.size = [0 for i in range(size)] self.size self size [0 for i in range(size)] 0 for i in range(size) for i in range(size) i range(size) range size for i in range(size) 0 self.p = [0 for i in range(size)] self.p self p [0 for i in range(size)] for i in range(size):
            self.makeSet(i)
    
     i range(size) range size self.makeSet(i) self.makeSet self makeSet i self self size size def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

     makeSet self.p[x] = x self.p[x] self.p self p x x self.size[x] = 1 self.size[x] self.size self size x 1 self self x x def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

     same return self.findSet(x) == self.findSet(y) self.findSet(x) == self.findSet(y) self.findSet(x) self.findSet self findSet x self.findSet(y) self.findSet self findSet y self self x x y y def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

     unite self.link(self.findSet(x), self.findSet(y)) self.link self link self.findSet(x) self.findSet self findSet x self.findSet(y) self.findSet self findSet y self self x x y y def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
     link if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
     self.size[x] > self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self.p[y] = x self.p[y] self.p self p 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.p[x] = y self.p[x] self.p self p x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x self self x x y y def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x] findSet if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
         x != self.p[x] x self.p[x] self.p self p x self.p[x] = self.findSet(self.p[x]) self.p[x] self.p self p x self.findSet(self.p[x]) self.findSet self findSet self.p[x] self.p self p x return self.p[x] self.p[x] self.p self p x self self x x N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ds = DisjointSet(N+1) ds DisjointSet(N+1) DisjointSet N+1 N 1 stack = [] stack [] ans = [N*(N-1)//2] ans [N*(N-1)//2] N*(N-1)//2 N*(N-1) N N-1 N 1 2 for m in range(M):
    a, b = map(int, input().split())
    stack += [(a, b)] m range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b stack += [(a, b)] stack [(a, b)] (a, b) a b for m in range(M):
    a, b = stack.pop()
    if ds.same(a, b):
        ans += [ans[-1]]
    else:
        ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]]
        ds.unite(a, b) m range(M) range M a, b = stack.pop() a stack.pop() stack.pop stack pop b if ds.same(a, b):
        ans += [ans[-1]]
    else:
        ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]]
        ds.unite(a, b) ds.same(a, b) ds.same ds same a b ans += [ans[-1]] ans [ans[-1]] ans[-1] ans -1 ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]] ans [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]] ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)] ans[-1] ans -1 ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)] ds.size[ds.findSet(a)] ds.size ds size ds.findSet(a) ds.findSet ds findSet a ds.size[ds.findSet(b)] ds.size ds size ds.findSet(b) ds.findSet ds findSet b ds.unite(a, b) ds.unite ds unite a b ans = ans[::-1] ans ans[::-1] ans ::-1 -1 for i in range(1, M+1):
    print(ans[i]) i range(1, M+1) range 1 M+1 M 1 print(ans[i]) print ans[i] ans i ans += [ans[-1]] [ans[-1]] ans N, M = map(int, input().split()) map(int, input().split()) N a, b = stack.pop() stack.pop() a b = stack.pop() stack.pop() b stack = [] [] stack b = map(int, input().split()) map(int, input().split()) b M = map(int, input().split()) map(int, input().split()) M stack += [(a, b)] [(a, b)] stack class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x] class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x] DisjointSet a, b = map(int, input().split()) map(int, input().split()) a ds = DisjointSet(N+1) DisjointSet(N+1) ds ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]] [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]] ans ans = [N*(N-1)//2] [N*(N-1)//2] ans ans = ans[::-1] ans[::-1] ans
# union by sixe
class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

N, M = map(int, input().split())
ds = DisjointSet(N+1) 
stack = []
ans = [N*(N-1)//2]
for m in range(M):
    a, b = map(int, input().split())
    stack += [(a, b)]
for m in range(M):
    a, b = stack.pop()
    if ds.same(a, b):
        ans += [ans[-1]]
    else:
        ans += [ans[-1] - ds.size[ds.findSet(a)] * ds.size[ds.findSet(b)]]
        ds.unite(a, b)
ans = ans[::-1]
for i in range(1, M+1):
    print(ans[i])
