import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

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

    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.par) 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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def main():
    N, M = NMI()
    edges = [NLI() for _ in range(M)]

    uf = UnionFind(N)
    ans = [0]*(M+1)
    for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

    for a in ans[1:]:
        print(a)

if __name__ == "__main__":
    main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input [int(num)] * w for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) [int(num)] * w [int(num)] int(num) int num w def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid h h w w num num class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

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

    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.par) 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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order UnionFind def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

     __init__ -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 self.par = [-1 for i in range(n)] self.par self par [-1 for i in range(n)] self.n = n self.n self n n self self n n def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     self.par[x] < 0 self.par[x] self.par self par x 0 return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par x self self x x def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

     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 if self.par[x] > self.par[y]:
            x, y = y, x

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

     size return -self.par[self.find(x)] -self.par[self.find(x)] self.par[self.find(x)] self.par self par self.find(x) self.find self find x self self x x 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.par) if x < 0]

     roots i for i, x in enumerate(self.par) if x < 0 for i, x in enumerate(self.par) if x < 0 i x enumerate(self.par) enumerate self.par self par x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.par) if x < 0] [i for i, x in enumerate(self.par) 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 def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order __str__ return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) '\n'.join '\n' join '{}: {}'.format(r, self.members(r)) '{}: {}'.format '{}: {}' format r self.members(r) self.members self members r self self def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res make_adjlist_nond [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] res = [[] for _ in range(n+1)] res [[] for _ in range(n+1)] for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
     edge edges res[edge[0]].append(edge[1]) [edge[0]].append [edge[0]] res edge[0] edge 0 append edge[1] edge 1 res[edge[1]].append(edge[0]) [edge[1]].append [edge[1]] res edge[1] edge 1 append edge[0] edge 0 return res res n n edges edges def main():
    N, M = NMI()
    edges = [NLI() for _ in range(M)]

    uf = UnionFind(N)
    ans = [0]*(M+1)
    for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

    for a in ans[1:]:
        print(a) main N, M = NMI() N NMI() NMI M NLI() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) NLI() NLI edges = [NLI() for _ in range(M)] edges [NLI() for _ in range(M)] uf = UnionFind(N) uf UnionFind(N) UnionFind N ans = [0]*(M+1) ans [0]*(M+1) [0] 0 M+1 M 1 for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

     i range(M, 0, -1) range M 0 -1 if i == M:
            ans[i] = N * (N - 1) // 2
            continue

         i == M i M ans[i] = N * (N - 1) // 2 ans[i] ans i N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 continue x, y = edges[i][0] - 1, edges[i][1] - 1 x edges[i][0] - 1 edges[i][0] [i] edges i 0 1 y edges[i][1] - 1 edges[i][1] [i] edges i 1 1 if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
         uf.is_same(x, y) uf.is_same uf is_same x y ans[i] = ans[i+1] ans[i] ans i ans[i+1] ans i+1 i 1 continue num = uf.size(x) * uf.size(y) num uf.size(x) * uf.size(y) uf.size(x) uf.size uf size x uf.size(y) uf.size uf size y uf.unite(x, y) uf.unite uf unite x y ans[i] = ans[i+1] - num ans[i] ans i ans[i+1] - num ans[i+1] ans i+1 i 1 num for a in ans[1:]:
        print(a) a ans[1:] ans 1: 1 print(a) print a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res make_adjlist_nond input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input SI = lambda: input() lambda: input() SI MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD NI = lambda: int(input()) lambda: int(input()) NI def main():
    N, M = NMI()
    edges = [NLI() for _ in range(M)]

    uf = UnionFind(N)
    ans = [0]*(M+1)
    for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

    for a in ans[1:]:
        print(a) def main():
    N, M = NMI()
    edges = [NLI() for _ in range(M)]

    uf = UnionFind(N)
    ans = [0]*(M+1)
    for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

    for a in ans[1:]:
        print(a) main NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI NLI = lambda: list(NMI()) lambda: list(NMI()) NLI class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

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

    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.par) 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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

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

    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.par) 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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order UnionFind def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        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.par[x] > self.par[y]:
            x, y = y, x

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

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

    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.par) 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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#隣接リスト 1-order
def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n+1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def main():
    N, M = NMI()
    edges = [NLI() for _ in range(M)]

    uf = UnionFind(N)
    ans = [0]*(M+1)
    for i in range(M, 0, -1):
        if i == M:
            ans[i] = N * (N - 1) // 2
            continue

        x, y = edges[i][0] - 1, edges[i][1] - 1
        if uf.is_same(x, y):
            ans[i] = ans[i+1]
            continue
        num = uf.size(x) * uf.size(y)
        uf.unite(x, y)
        ans[i] = ans[i+1] - num

    for a in ans[1:]:
        print(a)

if __name__ == "__main__":
    main()