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]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
uf = UnionFind(n)
ans = [cmb(n, 2)]
cnt = cmb(n, 2)
for i in range(m-1, -1, -1):
    a, b = list_AB[i]
    p, q = uf.size(a-1), uf.size(b-1)
    uf.union(a-1, b-1)
    r = uf.size(a-1)
    if p != r:
        if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

        if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

        cnt -= cmb(r, 2) - x - y
    ans.append(cnt)

ans.reverse()
for i in range(1, m+1):
    print(ans[i])

 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]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()} 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 def group_count(self):
        return len(self.roots())

     group_count return len(self.roots()) len(self.roots()) len self.roots() self.roots self roots self self def all_group_members(self):
        return {r: self.members(r) for r in self.roots()} all_group_members r: self.members(r) for r in self.roots() for r in self.roots() r self.roots() self.roots self roots for r in self.roots() r self.members(r) self.members self members r return {r: self.members(r) for r in self.roots()} {r: self.members(r) for r in self.roots()} self self from operator import mul from functools import reduce def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under cmb r = min(n-r,r) r min(n-r,r) min n-r n r r if r == 0: return 1
     r == 0 r 0 over = reduce(mul, range(n, n - r, -1)) over reduce(mul, range(n, n - r, -1)) reduce mul range(n, n - r, -1) range n n - r n r -1 under = reduce(mul, range(1,r + 1)) under reduce(mul, range(1,r + 1)) reduce mul range(1,r + 1) range 1 r + 1 r 1 return over // under over // under over under n n r r 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 " " list_AB = [ list(map(int,input().split(" "))) for i in range(m)] list_AB [ list(map(int,input().split(" "))) for i in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n ans = [cmb(n, 2)] ans [cmb(n, 2)] cmb(n, 2) cmb n 2 cnt = cmb(n, 2) cnt cmb(n, 2) cmb n 2 for i in range(m-1, -1, -1):
    a, b = list_AB[i]
    p, q = uf.size(a-1), uf.size(b-1)
    uf.union(a-1, b-1)
    r = uf.size(a-1)
    if p != r:
        if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

        if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

        cnt -= cmb(r, 2) - x - y
    ans.append(cnt) i range(m-1, -1, -1) range m-1 m 1 -1 -1 a, b = list_AB[i] a list_AB[i] list_AB i b p, q = uf.size(a-1), uf.size(b-1) p uf.size(a-1) uf.size uf size a-1 a 1 q uf.size(b-1) uf.size uf size b-1 b 1 uf.union(a-1, b-1) uf.union uf union a-1 a 1 b-1 b 1 r = uf.size(a-1) r uf.size(a-1) uf.size uf size a-1 a 1 if p != r:
        if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

        if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

        cnt -= cmb(r, 2) - x - y
     p != r p r if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

         p == 1 p 1 x = 0 x 0 x = cmb(p, 2) x cmb(p, 2) cmb p 2 if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

         q == 1 q 1 y = 0 y 0 y = cmb(q, 2) y cmb(q, 2) cmb q 2 cnt -= cmb(r, 2) - x - y cnt cmb(r, 2) - x - y cmb(r, 2) - x cmb(r, 2) cmb r 2 x y ans.append(cnt) ans.append ans append cnt ans.reverse() ans.reverse ans reverse 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 x = 0 0 x y = cmb(q, 2) cmb(q, 2) y y = 0 0 y def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under cmb cnt = cmb(n, 2) cmb(n, 2) cnt q = uf.size(a-1), uf.size(b-1) uf.size(b-1) q x = cmb(p, 2) cmb(p, 2) x cnt -= cmb(r, 2) - x - y cmb(r, 2) - x - y cnt m = map(int, input().split()) map(int, input().split()) m ans = [cmb(n, 2)] [cmb(n, 2)] ans r = uf.size(a-1) uf.size(a-1) r n, m = map(int, input().split()) map(int, input().split()) n list_AB = [ list(map(int,input().split(" "))) for i in range(m)] [ list(map(int,input().split(" "))) for i in range(m)] list_AB b = list_AB[i] list_AB[i] 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]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()} 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]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()} UnionFind p, q = uf.size(a-1), uf.size(b-1) uf.size(a-1) p uf = UnionFind(n) UnionFind(n) uf a, b = list_AB[i] list_AB[i] a
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]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(m)]
uf = UnionFind(n)
ans = [cmb(n, 2)]
cnt = cmb(n, 2)
for i in range(m-1, -1, -1):
    a, b = list_AB[i]
    p, q = uf.size(a-1), uf.size(b-1)
    uf.union(a-1, b-1)
    r = uf.size(a-1)
    if p != r:
        if p == 1:
            x = 0
        else:
            x = cmb(p, 2)

        if q == 1:
            y = 0
        else:
            y = cmb(q, 2)

        cnt -= cmb(r, 2) - x - y
    ans.append(cnt)

ans.reverse()
for i in range(1, m+1):
    print(ans[i])


