class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
      
n, m = map(int, input().split())
e = [list(map(int,input().split())) for i in range(m)]
e.reverse()

uf = UnionFind(n)
score = n*(n-1)//2 
ans = [score]
for ce in range(m-1):
    u, v = e[ce][0]-1, e[ce][1]-1
    if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
    ans.append(score)
ans.reverse()

for i in range(m):
    print(ans[i]) class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
       UnionFind def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
     __init__ self.pars = list(range(numV)) self.pars self pars list(range(numV)) list range(numV) range numV self.ranks = [0] * numV self.ranks self ranks [0] * numV [0] 0 numV self.sizes = [1] * numV self.sizes self sizes [1] * numV [1] 1 numV self self numV numV def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
     getRoot par = self.pars[x] par self.pars[x] self.pars self pars x if par != x:
            self.pars[x] = par = self.getRoot(par)
         par != x par x self.pars[x] = par = self.getRoot(par) self.pars[x] self.pars self pars x self.getRoot(par) self.getRoot self getRoot par = par = self.getRoot(par) par self.getRoot(par) return par par self self x x def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
     merge x, y = self.getRoot(x), self.getRoot(y) x self.getRoot(x) self.getRoot self getRoot x y self.getRoot(y) self.getRoot self getRoot y sx, sy = self.sizes[x], self.sizes[y] sx self.sizes[x] self.sizes self sizes x sy self.sizes[y] self.sizes self sizes y if x == y: return (0, 0)
         x == y x y if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
         self.ranks[x] < self.ranks[y] self.ranks[x] self.ranks self ranks x self.ranks[y] self.ranks self ranks y self.pars[x] = y self.pars[x] self.pars self pars x y self.sizes[y] += sx self.sizes[y] self.sizes self sizes y sx self.pars[y] = x self.pars[y] self.pars self pars y x self.sizes[x] += sy self.sizes[x] self.sizes self sizes x sy if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
         self.ranks[x] == self.ranks[y] self.ranks[x] self.ranks self ranks x self.ranks[y] self.ranks self ranks y self.ranks[x] += 1 self.ranks[x] self.ranks self ranks x 1 return (sx, sy) (sx, sy) sx sy self self x x y y def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
     isSame return self.getRoot(x) == self.getRoot(y) self.getRoot(x) == self.getRoot(y) self.getRoot(x) self.getRoot self getRoot x self.getRoot(y) self.getRoot self getRoot y self self x x y y def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
     updatePars for v in range(len(self.pars)):
            self.getRoot(v)
     v range(len(self.pars)) range len(self.pars) len self.pars self pars self.getRoot(v) self.getRoot self getRoot v self self def getSize(self, x):
        return self.sizes[self.getRoot(x)]
       getSize return self.sizes[self.getRoot(x)] self.sizes[self.getRoot(x)] self.sizes self sizes self.getRoot(x) self.getRoot self getRoot x self self x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split e = [list(map(int,input().split())) for i in range(m)] e [list(map(int,input().split())) for i in range(m)] e.reverse() e.reverse e reverse uf = UnionFind(n) uf UnionFind(n) UnionFind n score = n*(n-1)//2 score n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans = [score] ans [score] score for ce in range(m-1):
    u, v = e[ce][0]-1, e[ce][1]-1
    if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
    ans.append(score) ce range(m-1) range m-1 m 1 u, v = e[ce][0]-1, e[ce][1]-1 u e[ce][0]-1 e[ce][0] [ce] e ce 0 1 v e[ce][1]-1 e[ce][1] [ce] e ce 1 1 if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
     uf.getRoot(u) != uf.getRoot(v) uf.getRoot(u) uf.getRoot uf getRoot u uf.getRoot(v) uf.getRoot uf getRoot v xu = uf.getSize(u) xu uf.getSize(u) uf.getSize uf getSize u xv = uf.getSize(v) xv uf.getSize(v) uf.getSize uf getSize v uf.merge(u, v) uf.merge uf merge u v score -= xu * xv score xu * xv xu xv ans.append(score) ans.append ans append score ans.reverse() ans.reverse ans reverse for i in range(m):
    print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i xv = uf.getSize(v) uf.getSize(v) xv m = map(int, input().split()) map(int, input().split()) m v = e[ce][0]-1, e[ce][1]-1 e[ce][1]-1 v uf = UnionFind(n) UnionFind(n) uf n, m = map(int, input().split()) map(int, input().split()) n ans = [score] [score] ans u, v = e[ce][0]-1, e[ce][1]-1 e[ce][0]-1 u e = [list(map(int,input().split())) for i in range(m)] [list(map(int,input().split())) for i in range(m)] e score = n*(n-1)//2 n*(n-1)//2 score class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
       class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
       UnionFind xu = uf.getSize(u) uf.getSize(u) xu score -= xu * xv xu * xv score
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
      
n, m = map(int, input().split())
e = [list(map(int,input().split())) for i in range(m)]
e.reverse()

uf = UnionFind(n)
score = n*(n-1)//2 
ans = [score]
for ce in range(m-1):
    u, v = e[ce][0]-1, e[ce][1]-1
    if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
    ans.append(score)
ans.reverse()

for i in range(m):
    print(ans[i])