from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

dp = [0] * (M + 1)
dp[-1] = N * (N - 1) // 2
union_find = UnionFind(N)

for i in reversed(range(M)):
    if dp[i + 1] == 0:
        break
    a, b = edges[i]
    minus = union_find.union(a, b)
    dp[i] = dp[i + 1] - minus

for i in range(M):
    print(dp[i + 1]) from collections import deque, Counter class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b) UnionFind def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

     __init__ self.v = v self.v self v v self._tree = list(range(v + 1)) self._tree self _tree list(range(v + 1)) list range(v + 1) range v + 1 v 1 self._counter = Counter(self._tree) self._counter self _counter Counter(self._tree) Counter self._tree self _tree self self v v def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

     _root queue = deque() queue deque() deque while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
         self._tree[a] != a self._tree[a] self._tree self _tree a a queue.append(a) queue.append queue append a a = self._tree[a] a self._tree[a] self._tree self _tree a while queue:
            index = queue.popleft()
            self._tree[index] = a
         queue index = queue.popleft() index queue.popleft() queue.popleft queue popleft self._tree[index] = a self._tree[index] self._tree self _tree index a return a a self self a a def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

     union root_a = self._root(a) root_a self._root(a) self._root self _root a root_b = self._root(b) root_b self._root(b) self._root self _root b if root_a == root_b:
            return 0

         root_a == root_b root_a root_b return 0 0 self._tree[root_b] = root_a self._tree[root_b] self._tree self _tree root_b root_a ca = self._counter[root_a] ca self._counter[root_a] self._counter self _counter root_a cb = self._counter[root_b] cb self._counter[root_b] self._counter self _counter root_b self._counter[root_a] += cb self._counter[root_a] self._counter self _counter root_a cb self._counter[root_b] = 0 self._counter[root_b] self._counter self _counter root_b 0 return ca * cb ca * cb ca cb self self a a b b def find(self, a, b):
        return self._root(a) == self._root(b) find return self._root(a) == self._root(b) self._root(a) == self._root(b) self._root(a) self._root self _root a self._root(b) self._root self _root b self self a a b b N, M = map(int, input().split(' ')) N map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' M tuple(map(int, input().split(' '))) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(int, input().split(' '))) tuple map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' edges = [tuple(map(int, input().split(' '))) for _ in range(M)] edges [tuple(map(int, input().split(' '))) for _ in range(M)] dp = [0] * (M + 1) dp [0] * (M + 1) [0] 0 M + 1 M 1 dp[-1] = N * (N - 1) // 2 dp[-1] dp -1 N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 union_find = UnionFind(N) union_find UnionFind(N) UnionFind N for i in reversed(range(M)):
    if dp[i + 1] == 0:
        break
    a, b = edges[i]
    minus = union_find.union(a, b)
    dp[i] = dp[i + 1] - minus i reversed(range(M)) reversed range(M) range M if dp[i + 1] == 0:
        break
     dp[i + 1] == 0 dp[i + 1] dp i + 1 i 1 0 break a, b = edges[i] a edges[i] edges i b minus = union_find.union(a, b) minus union_find.union(a, b) union_find.union union_find union a b dp[i] = dp[i + 1] - minus dp[i] dp i dp[i + 1] - minus dp[i + 1] dp i + 1 i 1 minus for i in range(M):
    print(dp[i + 1]) i range(M) range M print(dp[i + 1]) print dp[i + 1] dp i + 1 i 1 minus = union_find.union(a, b) union_find.union(a, b) minus M = map(int, input().split(' ')) map(int, input().split(' ')) M union_find = UnionFind(N) UnionFind(N) union_find edges = [tuple(map(int, input().split(' '))) for _ in range(M)] [tuple(map(int, input().split(' '))) for _ in range(M)] edges N, M = map(int, input().split(' ')) map(int, input().split(' ')) N a, b = edges[i] edges[i] a b = edges[i] edges[i] b dp = [0] * (M + 1) [0] * (M + 1) dp class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b) class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b) UnionFind
from collections import deque, Counter


class UnionFind:
    def __init__(self, v):
        self.v = v
        self._tree = list(range(v + 1))
        self._counter = Counter(self._tree)

    def _root(self, a):
        queue = deque()
        while self._tree[a] != a:
            queue.append(a)
            a = self._tree[a]
        while queue:
            index = queue.popleft()
            self._tree[index] = a
        return a

    def union(self, a, b):
        root_a = self._root(a)
        root_b = self._root(b)
        if root_a == root_b:
            return 0

        self._tree[root_b] = root_a
        ca = self._counter[root_a]
        cb = self._counter[root_b]
        self._counter[root_a] += cb
        self._counter[root_b] = 0
        return ca * cb

    def find(self, a, b):
        return self._root(a) == self._root(b)


N, M = map(int, input().split(' '))
edges = [tuple(map(int, input().split(' '))) for _ in range(M)]

dp = [0] * (M + 1)
dp[-1] = N * (N - 1) // 2
union_find = UnionFind(N)

for i in reversed(range(M)):
    if dp[i + 1] == 0:
        break
    a, b = edges[i]
    minus = union_find.union(a, b)
    dp[i] = dp[i + 1] - minus

for i in range(M):
    print(dp[i + 1])
