import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    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.parents) 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())
    
def main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
    
if __name__ == "__main__":
    main() import sys sys import math math from collections import defaultdict, deque, Counter from copy import deepcopy from bisect import bisect, bisect_right, bisect_left from heapq import heapify, heappop, heappush input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def RD(): return input().rstrip() RD def F(): return float(input().rstrip()) F def I(): return int(input().rstrip()) I def MI(): return map(int, input().split()) MI def MF(): return map(float,input().split()) MF def LI(): return list(map(int, input().split())) LI def TI(): return tuple(map(int, input().split())) TI def LF(): return list(map(float,input().split())) LF [num for i in range(W)] for j in range(H) for j in range(H) j range(H) range H for j in range(H) [num for i in range(W)] def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] Init H H W W num num class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    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.parents) 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())
     UnionFind """
    要素数nで初期化
    """ def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self self n n def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

     union """
        union(x, y)でx, yをグルーピング
        """ 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.parents[x] > self.parents[y]:
            x, y = y, x

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

     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

     same """
        same(x, y)同じグループに属しているか
        """ 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 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.parents) if x < 0]

     roots i for i, x in enumerate(self.parents) if x < 0 for i, x in enumerate(self.parents) if x < 0 i x enumerate(self.parents) enumerate self.parents self parents x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.parents) if x < 0] [i for i, x in enumerate(self.parents) 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())
     __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 main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
     main N, M = MI() N MI() MI M Union = UnionFind(N) Union UnionFind(N) UnionFind N Num = N*(N-1) // 2 Num N*(N-1) // 2 N*(N-1) N N-1 N 1 2 res = [0]*M res [0]*M [0] 0 M res[0] = Num res[0] res 0 Num LI() for i in range(M) for i in range(M) i range(M) range M for i in range(M) LI() LI L = [LI() for i in range(M)] L [LI() for i in range(M)] for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

     index l enumerate(reversed(L[1:])) enumerate reversed(L[1:]) reversed L[1:] L 1: 1 a, b = l a l b if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
         not Union.same(a-1, b-1) Union.same(a-1, b-1) Union.same Union same a-1 a 1 b-1 b 1 res[index+1] -= Union.size(a-1) * Union.size(b-1) res[index+1] res index+1 index 1 Union.size(a-1) * Union.size(b-1) Union.size(a-1) Union.size Union size a-1 a 1 Union.size(b-1) Union.size Union size b-1 b 1 res[index+1] += res[index] res[index+1] res index+1 index 1 res[index] res index Union.union(a-1, b-1) Union.union Union union a-1 a 1 b-1 b 1 if res[index+1] == 0:
            break

     res[index+1] == 0 res[index+1] res index+1 index 1 0 break for i in reversed(res):
        print(i)
     i reversed(res) reversed res print(i) print i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def MF(): return map(float,input().split()) def MF(): return map(float,input().split()) MF class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    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.parents) 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())
     class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    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.parents) 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())
     UnionFind def LF(): return list(map(float,input().split())) def LF(): return list(map(float,input().split())) LF def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def F(): return float(input().rstrip()) def F(): return float(input().rstrip()) F def I(): return int(input().rstrip()) def I(): return int(input().rstrip()) I def TI(): return tuple(map(int, input().split())) def TI(): return tuple(map(int, input().split())) TI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI def main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
     def main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
     main def RD(): return input().rstrip() def RD(): return input().rstrip() RD input = sys.stdin.readline sys.stdin.readline input def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] def Init(H, W, num): return [[num for i in range(W)] for j in range(H)] Init
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

class UnionFind():
    """
    要素数nで初期化
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        """
        union(x, y)でx, yをグルーピング
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

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

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

    def same(self, x, y):
        """
        same(x, y)同じグループに属しているか
        """
        return self.find(x) == self.find(y)

    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.parents) 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())
    
def main():
    N, M = MI()
    Union = UnionFind(N)
    Num = N*(N-1) // 2
    res = [0]*M
    res[0] = Num
    L = [LI() for i in range(M)]
    
    for index, l in enumerate(reversed(L[1:])):
        a, b = l
        if not Union.same(a-1, b-1):
            res[index+1] -= Union.size(a-1) * Union.size(b-1)
        res[index+1] += res[index]
        Union.union(a-1, b-1)
        if res[index+1] == 0:
            break

    for i in reversed(res):
        print(i)
    
if __name__ == "__main__":
    main()