n,m=map(int,input().split())
ab=[]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ab.append((a,b))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
uf=UnionFind(n)
ans=[n*(n-1)//2]
for i in range(m):
  a,b=ab[m-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    asize=uf.size(a)
    bsize=uf.size(b)
    ans.append(ans[-1]-asize*bsize)
    uf.union(a,b)
for i in range(m):
  print(ans[m-i-1]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ab=[] ab [] for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ab.append((a,b)) _ 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 class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0] UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self self n n def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     find if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

     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

         x == y x y return if self.parents[x] > self.parents[y]:
            x, y = y, x

         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x, y = y, x x y y x self.parents[x] += self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x self self x x y y def size(self, x):
        return -self.parents[self.find(x)]

     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x 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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

     members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if self.find(i) == root for i in range(self.n) if self.find(i) == root i range(self.n) range self.n self n self.find(i) == root self.find(i) self.find self find i root if self.find(i) == root i return [i for i in range(self.n) if self.find(i) == root] [i for i in range(self.n) if self.find(i) == root] self self x x def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0] roots i for i, x in enumerate(self.parents) if x < 0 for i, x in enumerate(self.parents) if x < 0 i x enumerate(self.parents) enumerate self.parents self parents x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.parents) if x < 0] [i for i, x in enumerate(self.parents) if x < 0] self self uf=UnionFind(n) uf UnionFind(n) UnionFind n ans=[n*(n-1)//2] ans [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in range(m):
  a,b=ab[m-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    asize=uf.size(a)
    bsize=uf.size(b)
    ans.append(ans[-1]-asize*bsize)
    uf.union(a,b) i range(m) range m a,b=ab[m-i-1] a ab[m-i-1] ab m-i-1 m-i m i 1 b if uf.same(a,b):
    ans.append(ans[-1])
  else:
    asize=uf.size(a)
    bsize=uf.size(b)
    ans.append(ans[-1]-asize*bsize)
    uf.union(a,b) uf.same(a,b) uf.same uf same a b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 asize=uf.size(a) asize uf.size(a) uf.size uf size a bsize=uf.size(b) bsize uf.size(b) uf.size uf size b ans.append(ans[-1]-asize*bsize) ans.append ans append ans[-1]-asize*bsize ans[-1] ans -1 asize*bsize asize bsize uf.union(a,b) uf.union uf union a b for i in range(m):
  print(ans[m-i-1]) i range(m) range m print(ans[m-i-1]) print ans[m-i-1] ans m-i-1 m-i m i 1 b=map(int,input().split()) map(int,input().split()) b m=map(int,input().split()) map(int,input().split()) m ab=[] [] ab asize=uf.size(a) uf.size(a) asize class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0] class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0] UnionFind b-=1 1 b b=ab[m-i-1] ab[m-i-1] b uf=UnionFind(n) UnionFind(n) uf bsize=uf.size(b) uf.size(b) bsize a,b=ab[m-i-1] ab[m-i-1] a ans=[n*(n-1)//2] [n*(n-1)//2] ans a-=1 1 a n,m=map(int,input().split()) map(int,input().split()) n a,b=map(int,input().split()) map(int,input().split()) a
n,m=map(int,input().split())
ab=[]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  ab.append((a,b))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
uf=UnionFind(n)
ans=[n*(n-1)//2]
for i in range(m):
  a,b=ab[m-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
  else:
    asize=uf.size(a)
    bsize=uf.size(b)
    ans.append(ans[-1]-asize*bsize)
    uf.union(a,b)
for i in range(m):
  print(ans[m-i-1])