import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

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

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

def resolve():
    N, M = LI()
    AB = [LI_() for _ in range(M)]
    ans = [N*(N-1)//2]
    uf = UnionFind(N)
    for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
    ans.pop()
        
    for i in reversed(ans):
        print(i)


if __name__ == '__main__':
    resolve() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**20 INF 10**20 10 20 def I(): return int(input()) I def F(): return float(input()) F def S(): return input() S int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI(): return [int(x) for x in input().split()] LI int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 def LI_(): return [int(x)-1 for x in input().split()] LI_ float(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() float(x) float x def LF(): return [float(x) for x in input().split()] LF def LS(): return input().split() LS class UnionFind():
    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 unite(self, 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 same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)] UnionFind 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 unite(self, 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

     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.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 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):
        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 resolve():
    N, M = LI()
    AB = [LI_() for _ in range(M)]
    ans = [N*(N-1)//2]
    uf = UnionFind(N)
    for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
    ans.pop()
        
    for i in reversed(ans):
        print(i) resolve N, M = LI() N LI() LI M LI_() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) LI_() LI_ AB = [LI_() for _ in range(M)] AB [LI_() for _ in range(M)] ans = [N*(N-1)//2] ans [N*(N-1)//2] N*(N-1)//2 N*(N-1) N N-1 N 1 2 uf = UnionFind(N) uf UnionFind(N) UnionFind N for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
     A B reversed(AB) reversed AB A_size = uf.size(A) A_size uf.size(A) uf.size uf size A B_size = uf.size(B) B_size uf.size(B) uf.size uf size B connected_island_num = 0 connected_island_num 0 if not uf.same(A, B):
            connected_island_num = A_size*B_size
         not uf.same(A, B) uf.same(A, B) uf.same uf same A B connected_island_num = A_size*B_size connected_island_num A_size*B_size A_size B_size ans.append(ans[-1]-connected_island_num) ans.append ans append ans[-1]-connected_island_num ans[-1] ans -1 connected_island_num uf.unite(A, B) uf.unite uf unite A B ans.pop() ans.pop ans pop for i in reversed(ans):
        print(i) i reversed(ans) reversed ans print(i) print i if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def LS(): return input().split() def LS(): return input().split() LS def I(): return int(input()) def I(): return int(input()) I def S(): return input() def S(): return input() S def LI_(): return [int(x)-1 for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] LI_ def resolve():
    N, M = LI()
    AB = [LI_() for _ in range(M)]
    ans = [N*(N-1)//2]
    uf = UnionFind(N)
    for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
    ans.pop()
        
    for i in reversed(ans):
        print(i) def resolve():
    N, M = LI()
    AB = [LI_() for _ in range(M)]
    ans = [N*(N-1)//2]
    uf = UnionFind(N)
    for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
    ans.pop()
        
    for i in reversed(ans):
        print(i) resolve INF = 10**20 10**20 INF def LI(): return [int(x) for x in input().split()] def LI(): return [int(x) for x in input().split()] LI input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input class UnionFind():
    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 unite(self, 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 same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)] class UnionFind():
    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 unite(self, 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 same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)] UnionFind def F(): return float(input()) def F(): return float(input()) F def LF(): return [float(x) for x in input().split()] def LF(): return [float(x) for x in input().split()] LF
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

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

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

def resolve():
    N, M = LI()
    AB = [LI_() for _ in range(M)]
    ans = [N*(N-1)//2]
    uf = UnionFind(N)
    for A, B in reversed(AB):
        A_size = uf.size(A)
        B_size = uf.size(B)
        connected_island_num = 0
        if not uf.same(A, B):
            connected_island_num = A_size*B_size
        ans.append(ans[-1]-connected_island_num)
        uf.unite(A, B)
    # 崩落数0の分を除去
    ans.pop()
        
    for i in reversed(ans):
        print(i)


if __name__ == '__main__':
    resolve()