import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

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

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

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a)

N, M = map(int, input().split())
A, B = [None] * M, [None] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

uf = UnionFind(N)
ans = [None] * M
ans[M - 1] = N * (N - 1) // 2
for i in range(M - 1, 0, -1):
    x, y = A[i] - 1, B[i] - 1
    if uf.is_same(x, y):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - (uf.get_size(x) * uf.get_size(y))
    uf.unite(x, y)

for a in ans:
    print(a) import sys sys import itertools itertools import time time sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from collections import defaultdict read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

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

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

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a) UnionFind def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.link = [i for i in range(n)] self.link self link [i for i in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self.size = [1 for _ in range(n)] self.size self size [1 for _ in range(n)] self self n = 1 n 1 def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

     find if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
         self.link[x] == x self.link[x] self.link self link x x return x x self.link[x] = self.find(self.link[x]) self.link[x] self.link self link x self.find(self.link[x]) self.find self find self.link[x] self.link self link x return self.link[x] self.link[x] self.link self link x self self x x def is_same(self, x, y):
        return self.find(x) == self.find(y)

     is_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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
     unite 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.size[x] < self.size[y]:
            x, y = y, x
         self.size[x] < self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y x, y = y, x x y y x self.link[y] = x self.link[y] self.link self link 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 self x x y y def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a) get_size x = self.find(x) x self.find(x) self.find self find x return self.size[x] self.size[x] self.size self size x self self x x object N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A, B = [None] * M, [None] * M A [None] * M [None] None M B [None] * M [None] None M for i in range(M):
    A[i], B[i] = map(int, input().split()) i range(M) range M A[i], B[i] = map(int, input().split()) A[i] A i map(int, input().split()) map int input().split() ().split () input split B[i] B i uf = UnionFind(N) uf UnionFind(N) UnionFind N ans = [None] * M ans [None] * M [None] None M ans[M - 1] = N * (N - 1) // 2 ans[M - 1] ans M - 1 M 1 N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for i in range(M - 1, 0, -1):
    x, y = A[i] - 1, B[i] - 1
    if uf.is_same(x, y):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - (uf.get_size(x) * uf.get_size(y))
    uf.unite(x, y) i range(M - 1, 0, -1) range M - 1 M 1 0 -1 x, y = A[i] - 1, B[i] - 1 x A[i] - 1 A[i] A i 1 y B[i] - 1 B[i] B i 1 if uf.is_same(x, y):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - (uf.get_size(x) * uf.get_size(y))
     uf.is_same(x, y) uf.is_same uf is_same x y ans[i - 1] = ans[i] ans[i - 1] ans i - 1 i 1 ans[i] ans i ans[i - 1] = ans[i] - (uf.get_size(x) * uf.get_size(y)) ans[i - 1] ans i - 1 i 1 ans[i] - (uf.get_size(x) * uf.get_size(y)) ans[i] ans i uf.get_size(x) * uf.get_size(y) uf.get_size(x) uf.get_size uf get_size x uf.get_size(y) uf.get_size uf get_size y uf.unite(x, y) uf.unite uf unite x y for a in ans:
    print(a) a ans print(a) print a class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

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

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

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a) class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

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

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

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a) UnionFind read = sys.stdin.buffer.read sys.stdin.buffer.read read uf = UnionFind(N) UnionFind(N) uf A, B = [None] * M, [None] * M [None] * M A ans = [None] * M [None] * M ans readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline y = A[i] - 1, B[i] - 1 B[i] - 1 y M = map(int, input().split()) map(int, input().split()) M readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines N, M = map(int, input().split()) map(int, input().split()) N x, y = A[i] - 1, B[i] - 1 A[i] - 1 x B = [None] * M, [None] * M [None] * M B
import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

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

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

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

# from union_find import *

# n, m = map(int, readline().split())

# u = UnionFind(n)

# a = [0 for _ in range(m)]
# b = [0 for _ in range(m)]

# for i in range(m):
#     a[i], b[i] = map(lambda x: int(x) - 1, readline().split())

# ans = [None for _ in range(m)]

# ans[-1] = n * (n - 1) // 2

# for i in range(m - 1, 0, -1):
#     x = a[i]
#     y = b[i]
#     if u.is_same(x, y):
#         ans[i - 1] = ans[i]
#     else:
#         ans[i - 1] = ans[i] - (u.get_size(x) * u.get_size(y))
#     u.unite(x, y)

# for a in ans:
#     print(a)

N, M = map(int, input().split())
A, B = [None] * M, [None] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

uf = UnionFind(N)
ans = [None] * M
ans[M - 1] = N * (N - 1) // 2
for i in range(M - 1, 0, -1):
    x, y = A[i] - 1, B[i] - 1
    if uf.is_same(x, y):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - (uf.get_size(x) * uf.get_size(y))
    uf.unite(x, y)

for a in ans:
    print(a)