n, m = map(int, input().split())
bridges = []
island_connection = [1] * n
unconfortable = (n * (n - 1)) // 2
unconfortable_list = [unconfortable]


class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

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

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

    def is_root(self, x):
        return self.parent[x] < 0


connection = UnionFind(n)

for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array)

bridges = bridges[::-1]

for i, j in bridges:
    if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
    unconfortable_list.append(unconfortable)

for i in range(1, m+1):
    print(unconfortable_list[-1-i])
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m bridges = [] bridges [] island_connection = [1] * n island_connection [1] * n [1] 1 n unconfortable = (n * (n - 1)) // 2 unconfortable (n * (n - 1)) // 2 n * (n - 1) n n - 1 n 1 2 unconfortable_list = [unconfortable] unconfortable_list [unconfortable] unconfortable class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

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

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

    def is_root(self, x):
        return self.parent[x] < 0 UnionFind def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

     __init__ -1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) -1 self.parent = [-1 for _ in range(n)] self.parent self parent [-1 for _ in range(n)] self self n n def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

     find if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

     self.parent[x] < 0 self.parent[x] self.parent self parent x 0 return x x self.parent[x] = self.find(self.parent[x]) self.parent[x] self.parent self parent x self.find(self.parent[x]) self.find self find self.parent[x] self.parent self parent x return self.parent[x] self.parent[x] self.parent self parent x self self x x def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

     unite x, y = self.find(x), self.find(y) x self.find(x) self.find self find x y self.find(y) self.find self find y if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

     x == y x y return False False 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.parent[x] += self.parent[y] self.parent[x] self.parent self parent x self.parent[y] self.parent self parent y self.parent[y] = x self.parent[y] self.parent self parent y x self self x x y y 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 size(self, x):
        x = self.find(x)
        return -self.parent[x]

     size x = self.find(x) x self.find(x) self.find self find x return -self.parent[x] -self.parent[x] self.parent[x] self.parent self parent x self self x x def is_root(self, x):
        return self.parent[x] < 0 is_root return self.parent[x] < 0 self.parent[x] < 0 self.parent[x] self.parent self parent x 0 self self x x connection = UnionFind(n) connection UnionFind(n) UnionFind n for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array) i range(m) range m array = list(map(int, input().split())) array list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split array[0] -= 1 array[0] array 0 1 array[1] -= 1 array[1] array 1 1 bridges.append(array) bridges.append bridges append array bridges = bridges[::-1] bridges bridges[::-1] bridges ::-1 -1 for i, j in bridges:
    if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
    unconfortable_list.append(unconfortable) i j bridges if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
     connection.same(i,j) == 0 connection.same(i,j) connection.same connection same i j 0 p = connection.size(i) p connection.size(i) connection.size connection size i q = connection.size(j) q connection.size(j) connection.size connection size j if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
     p == 1 and q == 1 p == 1 p 1 q == 1 q 1 unconfortable -= 1 unconfortable 1 connection.unite(i, j) connection.unite connection unite i j unconfortable -= (p * q) unconfortable p * q p q connection.unite(i, j) connection.unite connection unite i j unconfortable_list.append(unconfortable) unconfortable_list.append unconfortable_list append unconfortable for i in range(1, m+1):
    print(unconfortable_list[-1-i]) i range(1, m+1) range 1 m+1 m 1 print(unconfortable_list[-1-i]) print unconfortable_list[-1-i] unconfortable_list -1-i -1 i n, m = map(int, input().split()) map(int, input().split()) n q = connection.size(j) connection.size(j) q unconfortable = (n * (n - 1)) // 2 (n * (n - 1)) // 2 unconfortable bridges = bridges[::-1] bridges[::-1] bridges unconfortable -= (p * q) p * q unconfortable bridges = [] [] bridges connection = UnionFind(n) UnionFind(n) connection island_connection = [1] * n [1] * n island_connection m = map(int, input().split()) map(int, input().split()) m unconfortable_list = [unconfortable] [unconfortable] unconfortable_list class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

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

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

    def is_root(self, x):
        return self.parent[x] < 0 class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

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

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

    def is_root(self, x):
        return self.parent[x] < 0 UnionFind p = connection.size(i) connection.size(i) p array = list(map(int, input().split())) list(map(int, input().split())) array unconfortable -= 1 1 unconfortable
n, m = map(int, input().split())
bridges = []
island_connection = [1] * n
unconfortable = (n * (n - 1)) // 2
unconfortable_list = [unconfortable]


class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

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

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

    def is_root(self, x):
        return self.parent[x] < 0


connection = UnionFind(n)

for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array)

bridges = bridges[::-1]

for i, j in bridges:
    if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
    unconfortable_list.append(unconfortable)

for i in range(1, m+1):
    print(unconfortable_list[-1-i])

