import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

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

    def union(self, x, y):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                
n,m = map(int,input().split())
ufpc = UnionFindPathCompression(n)
query = []
for i in range(m):
    a, b = (int(x) for x in input().split())
    a,b = a-1, b-1
    query.append([a,b])

ans = [0]*m
ans[m-1] = n*(n-1)//2
#queryを後ろから発行してunionfind
for i in range(m-2, -1, -1):
    a,b = query[i+1][0], query[i+1][1]
    if ufpc.find(a) == ufpc.find(b):
        ans[i] = ans[i+1]
    else:
        #親のサイズで不便さを計算
        ans[i] = ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]]

    ufpc.union(a,b)
for aa in ans:
    print(aa) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

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

    def union(self, x, y):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 UnionFindPathCompression def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

     __init__ self.parents = list(range(n)) self.parents self parents list(range(n)) list range(n) range n self.rank = [1]*n self.rank self rank [1]*n [1] 1 n self.group_size = [1]*n self.group_size self group_size [1]*n [1] 1 n self self n n def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

     self.parents[x] == x self.parents[x] self.parents self parents x x 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):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 union px = self.find(x) px self.find(x) self.find self find x py = self.find(y) py self.find(y) self.find self find y if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 px == py px py return if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 self.rank[px] < self.rank[py] self.rank[px] self.rank self rank px self.rank[py] self.rank self rank py self.parents[px] = py self.parents[px] self.parents self parents px py self.group_size[py] += self.group_size[px] self.group_size[py] self.group_size self group_size py self.group_size[px] self.group_size self group_size px self.parents[py] = px self.parents[py] self.parents self parents py px self.group_size[px] += self.group_size[py] self.group_size[px] self.group_size self group_size px self.group_size[py] self.group_size self group_size py if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 self.rank[px] == self.rank[py] self.rank[px] self.rank self rank px self.rank[py] self.rank self rank py self.rank[px] += 1 self.rank[px] self.rank self rank px 1 self self x x y y n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ufpc = UnionFindPathCompression(n) ufpc UnionFindPathCompression(n) UnionFindPathCompression n query = [] query [] for i in range(m):
    a, b = (int(x) for x in input().split())
    a,b = a-1, b-1
    query.append([a,b]) i range(m) range m 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 a, b = (int(x) for x in input().split()) a (int(x) for x in input().split()) b a,b = a-1, b-1 a a-1 a 1 b b-1 b 1 query.append([a,b]) query.append query append [a,b] a b ans = [0]*m ans [0]*m [0] 0 m ans[m-1] = n*(n-1)//2 ans[m-1] ans m-1 m 1 n*(n-1)//2 n*(n-1) n n-1 n 1 2 for i in range(m-2, -1, -1):
    a,b = query[i+1][0], query[i+1][1]
    if ufpc.find(a) == ufpc.find(b):
        ans[i] = ans[i+1]
    else:
        #親のサイズで不便さを計算
        ans[i] = ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]]

    ufpc.union(a,b) i range(m-2, -1, -1) range m-2 m 2 -1 -1 a,b = query[i+1][0], query[i+1][1] a query[i+1][0] [i+1] query i+1 i 1 0 b query[i+1][1] [i+1] query i+1 i 1 1 if ufpc.find(a) == ufpc.find(b):
        ans[i] = ans[i+1]
    else:
        #親のサイズで不便さを計算
        ans[i] = ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]]

     ufpc.find(a) == ufpc.find(b) ufpc.find(a) ufpc.find ufpc find a ufpc.find(b) ufpc.find ufpc find b ans[i] = ans[i+1] ans[i] ans i ans[i+1] ans i+1 i 1 ans[i] = ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]] ans[i] ans i ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]] ans[i+1] ans i+1 i 1 ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]] ufpc.group_size[ufpc.parents[a]] ufpc.group_size ufpc group_size ufpc.parents[a] ufpc.parents ufpc parents a ufpc.group_size[ufpc.parents[b]] ufpc.group_size ufpc group_size ufpc.parents[b] ufpc.parents ufpc parents b ufpc.union(a,b) ufpc.union ufpc union a b for aa in ans:
    print(aa) aa ans print(aa) print aa b = query[i+1][0], query[i+1][1] query[i+1][1] b class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

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

    def union(self, x, y):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

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

    def union(self, x, y):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                 UnionFindPathCompression b = a-1, b-1 b-1 b a,b = query[i+1][0], query[i+1][1] query[i+1][0] a n,m = map(int,input().split()) map(int,input().split()) n b = (int(x) for x in input().split()) (int(x) for x in input().split()) b input = sys.stdin.readline sys.stdin.readline input ans = [0]*m [0]*m ans m = map(int,input().split()) map(int,input().split()) m a,b = a-1, b-1 a-1 a query = [] [] query a, b = (int(x) for x in input().split()) (int(x) for x in input().split()) a ufpc = UnionFindPathCompression(n) UnionFindPathCompression(n) ufpc
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.group_size = [1]*n

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

    def union(self, x, y):
        #親を探す p = parentの意味
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.group_size[py] += self.group_size[px]
            else:
                self.parents[py] = px
                self.group_size[px] += self.group_size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1
                
n,m = map(int,input().split())
ufpc = UnionFindPathCompression(n)
query = []
for i in range(m):
    a, b = (int(x) for x in input().split())
    a,b = a-1, b-1
    query.append([a,b])

ans = [0]*m
ans[m-1] = n*(n-1)//2
#queryを後ろから発行してunionfind
for i in range(m-2, -1, -1):
    a,b = query[i+1][0], query[i+1][1]
    if ufpc.find(a) == ufpc.find(b):
        ans[i] = ans[i+1]
    else:
        #親のサイズで不便さを計算
        ans[i] = ans[i+1] - ufpc.group_size[ufpc.parents[a]] * ufpc.group_size[ufpc.parents[b]]

    ufpc.union(a,b)
for aa in ans:
    print(aa)
