import sys


class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

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

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u


def c2(n):
    return n*(n-1)//2


N, M = map(int, sys.stdin.readline().split())
E = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    E.append((a, b))

u = UnionFind(N)
r = c2(N)
result = [r]
for a, b in E[::-1]:
    na = u.size(a)
    nb = u.size(b)
    if u.unite(a, b):
        r -= na*nb
    result.append(r)

for r in result[-2::-1]:
    print(r) import sys sys class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

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

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u UnionFind def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

     __init__ self.d = [-1]*n self.d self d [-1]*n [-1] -1 n self.u = n self.u self u n self self n=0 n 0 def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

     root if self.d[x] < 0:
            return x
         self.d[x] < 0 self.d[x] self.d self d x 0 return x x self.d[x] = self.root(self.d[x]) self.d[x] self.d self d x self.root(self.d[x]) self.root self root self.d[x] self.d self d x return self.d[x] self.d[x] self.d self d x self self x x def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

     unite x, y = self.root(x), self.root(y) x self.root(x) self.root self root x y self.root(y) self.root self root 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.d[x] += self.d[y] self.d[x] self.d self d x self.d[y] self.d self d y self.d[y] = x self.d[y] self.d self d y x self.u -= 1 self.u self u 1 return True True self self x x y y def same(self, x, y):
        return self.root(x) == self.root(y)

     same return self.root(x) == self.root(y) self.root(x) == self.root(y) self.root(x) self.root self root x self.root(y) self.root self root y self self x x y y def size(self, x):
        return -self.d[self.root(x)]

     size return -self.d[self.root(x)] -self.d[self.root(x)] self.d[self.root(x)] self.d self d self.root(x) self.root self root x self self x x def num_union(self):
        return self.u num_union return self.u self.u self u self self def c2(n):
    return n*(n-1)//2 c2 return n*(n-1)//2 n*(n-1)//2 n*(n-1) n n-1 n 1 2 n n N, M = map(int, sys.stdin.readline().split()) N map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split M E = [] E [] for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    E.append((a, b)) line sys.stdin sys stdin a, b = map(int, line.split()) a map(int, line.split()) map int line.split() line.split line split b a -= 1 a 1 b -= 1 b 1 E.append((a, b)) E.append E append (a, b) a b u = UnionFind(N) u UnionFind(N) UnionFind N r = c2(N) r c2(N) c2 N result = [r] result [r] r for a, b in E[::-1]:
    na = u.size(a)
    nb = u.size(b)
    if u.unite(a, b):
        r -= na*nb
    result.append(r) a b E[::-1] E ::-1 -1 na = u.size(a) na u.size(a) u.size u size a nb = u.size(b) nb u.size(b) u.size u size b if u.unite(a, b):
        r -= na*nb
     u.unite(a, b) u.unite u unite a b r -= na*nb r na*nb na nb result.append(r) result.append result append r for r in result[-2::-1]:
    print(r) r result[-2::-1] result -2::-1 -2 -1 print(r) print r r = c2(N) c2(N) r b -= 1 1 b u = UnionFind(N) UnionFind(N) u b = map(int, line.split()) map(int, line.split()) b na = u.size(a) u.size(a) na r -= na*nb na*nb r def c2(n):
    return n*(n-1)//2 def c2(n):
    return n*(n-1)//2 c2 class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

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

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

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

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u UnionFind a, b = map(int, line.split()) map(int, line.split()) a nb = u.size(b) u.size(b) nb E = [] [] E M = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) M N, M = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) N a -= 1 1 a result = [r] [r] result
import sys


class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False
        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        self.u -= 1
        return True

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

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u


def c2(n):
    return n*(n-1)//2


N, M = map(int, sys.stdin.readline().split())
E = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    E.append((a, b))

u = UnionFind(N)
r = c2(N)
result = [r]
for a, b in E[::-1]:
    na = u.size(a)
    nb = u.size(b)
    if u.unite(a, b):
        r -= na*nb
    result.append(r)

for r in result[-2::-1]:
    print(r)
