n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

uf = UnionFind(n)
p = n * (n-1) // 2
ans = [p]
for ai, bi in reversed(ab):
    a_root = uf.find_root(ai-1)
    b_root = uf.find_root(bi-1)
    if a_root != b_root:
        a_size = uf.size[uf.find_root(ai-1)]
        b_size = uf.size[uf.find_root(bi-1)]
        p = p - a_size * b_size
        ans.append(p)
    else:
        ans.append(p)
    uf.merge(ai-1, bi-1)

print('\n'.join(map(str, reversed(ans[:-1])))) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m tuple(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split ab = [tuple(map(int, input().split())) for _ in range(m)] ab [tuple(map(int, input().split())) for _ in range(m)] class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y) UnionFind def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
     __init__ self.root = list(range(n)) self.root self root list(range(n)) list range(n) range n self.size = [1] * (n) self.size self size [1] * (n) [1] 1 n self self n n def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
     find_root root = self.root root self.root self root while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
         root[x] != x root[x] root x x root[x] = root[root[x]] root[x] root x root[root[x]] root root[x] root x x = root[x] x root[x] root x return x x self self x x def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
     merge x = self.find_root(x) x self.find_root(x) self.find_root self find_root x y = self.find_root(y) y self.find_root(y) self.find_root self find_root y if x == y:
            return
         x == y x y return sx,sy = self.size[x],self.size[y] sx self.size[x] self.size self size x sy self.size[y] self.size self size y if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
     sx < sy sx sy self.root[x] = y self.root[x] self.root self root x y self.size[y] += sx self.size[y] self.size self size y sx self.root[y] = x self.root[y] self.root self root y x self.size[x] += sy self.size[x] self.size self size x sy self self x x y y def same(self, x, y):
        return self.find_root(x) == self.find_root(y) same return self.find_root(x) == self.find_root(y) self.find_root(x) == self.find_root(y) self.find_root(x) self.find_root self find_root x self.find_root(y) self.find_root self find_root y self self x x y y uf = UnionFind(n) uf UnionFind(n) UnionFind n p = n * (n-1) // 2 p n * (n-1) // 2 n * (n-1) n n-1 n 1 2 ans = [p] ans [p] p for ai, bi in reversed(ab):
    a_root = uf.find_root(ai-1)
    b_root = uf.find_root(bi-1)
    if a_root != b_root:
        a_size = uf.size[uf.find_root(ai-1)]
        b_size = uf.size[uf.find_root(bi-1)]
        p = p - a_size * b_size
        ans.append(p)
    else:
        ans.append(p)
    uf.merge(ai-1, bi-1) ai bi reversed(ab) reversed ab a_root = uf.find_root(ai-1) a_root uf.find_root(ai-1) uf.find_root uf find_root ai-1 ai 1 b_root = uf.find_root(bi-1) b_root uf.find_root(bi-1) uf.find_root uf find_root bi-1 bi 1 if a_root != b_root:
        a_size = uf.size[uf.find_root(ai-1)]
        b_size = uf.size[uf.find_root(bi-1)]
        p = p - a_size * b_size
        ans.append(p)
    else:
        ans.append(p)
     a_root != b_root a_root b_root a_size = uf.size[uf.find_root(ai-1)] a_size uf.size[uf.find_root(ai-1)] uf.size uf size uf.find_root(ai-1) uf.find_root uf find_root ai-1 ai 1 b_size = uf.size[uf.find_root(bi-1)] b_size uf.size[uf.find_root(bi-1)] uf.size uf size uf.find_root(bi-1) uf.find_root uf find_root bi-1 bi 1 p = p - a_size * b_size p p - a_size * b_size p a_size * b_size a_size b_size ans.append(p) ans.append ans append p ans.append(p) ans.append ans append p uf.merge(ai-1, bi-1) uf.merge uf merge ai-1 ai 1 bi-1 bi 1 print('\n'.join(map(str, reversed(ans[:-1])))) print '\n'.join(map(str, reversed(ans[:-1]))) '\n'.join '\n' join map(str, reversed(ans[:-1])) map str reversed(ans[:-1]) reversed ans[:-1] ans :-1 -1 class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y) class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y) UnionFind a_size = uf.size[uf.find_root(ai-1)] uf.size[uf.find_root(ai-1)] a_size n, m = map(int, input().split()) map(int, input().split()) n b_size = uf.size[uf.find_root(bi-1)] uf.size[uf.find_root(bi-1)] b_size p = n * (n-1) // 2 n * (n-1) // 2 p ans = [p] [p] ans ab = [tuple(map(int, input().split())) for _ in range(m)] [tuple(map(int, input().split())) for _ in range(m)] ab a_root = uf.find_root(ai-1) uf.find_root(ai-1) a_root m = map(int, input().split()) map(int, input().split()) m uf = UnionFind(n) UnionFind(n) uf b_root = uf.find_root(bi-1) uf.find_root(bi-1) b_root p = p - a_size * b_size p - a_size * b_size p
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

uf = UnionFind(n)
p = n * (n-1) // 2
ans = [p]
for ai, bi in reversed(ab):
    a_root = uf.find_root(ai-1)
    b_root = uf.find_root(bi-1)
    if a_root != b_root:
        a_size = uf.size[uf.find_root(ai-1)]
        b_size = uf.size[uf.find_root(bi-1)]
        p = p - a_size * b_size
        ans.append(p)
    else:
        ans.append(p)
    uf.merge(ai-1, bi-1)

print('\n'.join(map(str, reversed(ans[:-1]))))
