class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

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


def main():
    n, m = map(int, input().split())
    bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    answer = [n * (n - 1) // 2 for _ in range(m)]
    uf = UnionFind(n)
    is_same_before = False
    size_a = 0
    size_b = 0
    for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
    for a in answer:
        print(a)


if __name__ == '__main__':
    main()
 class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)] UnionFind def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

     self.parent[target] < 0 self.parent[target] self.parent self parent target 0 return target target self.parent[target] = self.find(self.parent[target]) self.parent[target] self.parent self parent target self.find(self.parent[target]) self.find self find self.parent[target] self.parent self parent target return self.parent[target] self.parent[target] self.parent self parent target self self target target def is_same(self, x, y):
        return self.find(x) == self.find(y)

     is_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 union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

     union root_x = self.find(x) root_x self.find(x) self.find self find x root_y = self.find(y) root_y self.find(y) self.find self find y if root_x == root_y:
            return
         root_x == root_y root_x root_y return if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
         self.parent[root_x] > self.parent[root_y] self.parent[root_x] self.parent self parent root_x self.parent[root_y] self.parent self parent root_y root_x, root_y = root_y, root_x root_x root_y root_y root_x self.parent[root_x] += self.parent[root_y] self.parent[root_x] self.parent self parent root_x self.parent[root_y] self.parent self parent root_y self.parent[root_y] = root_x self.parent[root_y] self.parent self parent root_y root_x self self x x y y def get_size(self, x):
        return -self.parent[self.find(x)] get_size return -self.parent[self.find(x)] -self.parent[self.find(x)] self.parent[self.find(x)] self.parent self parent self.find(x) self.find self find x self self x x def main():
    n, m = map(int, input().split())
    bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    answer = [n * (n - 1) // 2 for _ in range(m)]
    uf = UnionFind(n)
    is_same_before = False
    size_a = 0
    size_b = 0
    for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
    for a in answer:
        print(a) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(lambda x: int(x) - 1, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(lambda x: int(x) - 1, input().split())) list map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)] bridge [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)] n * (n - 1) // 2 for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 answer = [n * (n - 1) // 2 for _ in range(m)] answer [n * (n - 1) // 2 for _ in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n is_same_before = False is_same_before False size_a = 0 size_a 0 size_b = 0 size_b 0 for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
     i range(-1, -m - 1, -1) range -1 -m - 1 -m m 1 -1 a, b = bridge[i] a bridge[i] bridge i b if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
         i < -1 i -1 answer[i] = answer[i + 1] answer[i] answer i answer[i + 1] answer i + 1 i 1 if not is_same_before:
                answer[i] -= size_a * size_b
         not is_same_before is_same_before answer[i] -= size_a * size_b answer[i] answer i size_a * size_b size_a size_b is_same_before = uf.is_same(a, b) is_same_before uf.is_same(a, b) uf.is_same uf is_same a b if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
         not is_same_before is_same_before size_a = uf.get_size(a) size_a uf.get_size(a) uf.get_size uf get_size a size_b = uf.get_size(b) size_b uf.get_size(b) uf.get_size uf get_size b uf.union(a, b) uf.union uf union a b for a in answer:
        print(a) a answer print(a) print a if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)] class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)] UnionFind def main():
    n, m = map(int, input().split())
    bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    answer = [n * (n - 1) // 2 for _ in range(m)]
    uf = UnionFind(n)
    is_same_before = False
    size_a = 0
    size_b = 0
    for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
    for a in answer:
        print(a) def main():
    n, m = map(int, input().split())
    bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    answer = [n * (n - 1) // 2 for _ in range(m)]
    uf = UnionFind(n)
    is_same_before = False
    size_a = 0
    size_b = 0
    for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
    for a in answer:
        print(a) main
class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

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


def main():
    n, m = map(int, input().split())
    bridge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    answer = [n * (n - 1) // 2 for _ in range(m)]
    uf = UnionFind(n)
    is_same_before = False
    size_a = 0
    size_b = 0
    for i in range(-1, -m - 1, -1):
        a, b = bridge[i]
        if i < -1:
            answer[i] = answer[i + 1]
            if not is_same_before:
                answer[i] -= size_a * size_b
        is_same_before = uf.is_same(a, b)
        if not is_same_before:
            size_a = uf.get_size(a)
            size_b = uf.get_size(b)
        uf.union(a, b)
    for a in answer:
        print(a)


if __name__ == '__main__':
    main()

