import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans


if __name__ == "__main__":
    for ans in main()[::-1]:
        print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
     __init__ self.nodes = n self.nodes self nodes n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self self n: int 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]

    # unite the group include element x and group include element y
     find if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
     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.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
     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.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
     self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.parents[y] += self.parents[x] self.parents[y] self.parents self parents y self.parents[x] self.parents self parents x self.parents[x] = y self.parents[x] self.parents self parents x y 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 if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
     self.rank[x] == self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x] += 1 self.rank[x] self.rank self rank x 1 self self x x y y def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
     get_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):
        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 main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans main int(i) for i in input().strip().split() for i in input().strip().split() i input().strip().split() ().strip().split ().strip() ().strip () input strip split for i in input().strip().split() int(i) int i N, M = [int(i) for i in input().strip().split()] N [int(i) for i in input().strip().split()] M links = [None] * M links [None] * M [None] None M for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

     i range(M) range M int(i)-1 for i in input().strip().split() for i in input().strip().split() i input().strip().split() ().strip().split ().strip() ().strip () input strip split for i in input().strip().split() int(i)-1 int(i) int i 1 links[i] = [int(i)-1 for i in input().strip().split()] links[i] links i [int(i)-1 for i in input().strip().split()] u = UnionFind(N) u UnionFind(N) UnionFind N ans = list() ans list() list x = N * (N - 1) // 2 x N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
     a b links[::-1] links ::-1 -1 ans.append(x) ans.append ans append x if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
         not u.same(a, b) u.same(a, b) u.same u same a b x -= u.get_size(a) * u.get_size(b) x u.get_size(a) * u.get_size(b) u.get_size(a) u.get_size u get_size a u.get_size(b) u.get_size u get_size b u.unite(a, b) u.unite u unite a b return ans ans if __name__ == "__main__":
    for ans in main()[::-1]:
        print(ans) __name__ == "__main__" __name__ "__main__" for ans in main()[::-1]:
        print(ans) ans main()[::-1] () main ::-1 -1 print(ans) print ans input = sys.stdin.readline sys.stdin.readline input class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans def main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans main
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class UnionFind:
    def __init__(self, n: int):
        self.nodes = n
        self.parents = [-1] * n
        self.rank = [0] * n

    # retrun the root of element x
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # unite the group include element x and group include element y
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[y] += self.parents[x]
            self.parents[x] = y
        else:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # get size of the gourp which element x belongs
    def get_size(self, x):
        return -self.parents[self.find(x)]

    # check if element x and element y is same group
    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M = [int(i) for i in input().strip().split()]
    links = [None] * M
    for i in range(M):
        links[i] = [int(i)-1 for i in input().strip().split()]

    u = UnionFind(N)
    ans = list()
    x = N * (N - 1) // 2

    for a, b in links[::-1]:
        ans.append(x)
        if not u.same(a, b):
            x -= u.get_size(a) * u.get_size(b)
        u.unite(a, b)
    return ans


if __name__ == "__main__":
    for ans in main()[::-1]:
        print(ans)
