

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

    def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return


def submit():
    n, m = map(int, input().split())
    bridge = [tuple(map(int, input().split())) for _ in range(m)]

    uf = UnionFind(n)
    curr = n * (n - 1) // 2
    ans = []
    for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


    for a in reversed(ans):
        print(a)


submit()
    
        
 class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

    def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return UnionFind def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

     __init__ i for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) i self.par = [i for i in range(n + 1)] self.par self par [i for i in range(n + 1)] 1 for i in range(n + 1) for i in range(n + 1) i range(n + 1) range n + 1 n 1 for i in range(n + 1) 1 self.size = [1 for i in range(n + 1)] self.size self size [1 for i in range(n + 1)] self self n n def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
     find if x == self.par[x]:
            return x
         x == self.par[x] x self.par[x] self.par self par x return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par 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 union_size(self, x):
        return self.size[self.find(x)]

     union_size return self.size[self.find(x)] self.size[self.find(x)] self.size self size self.find(x) self.find self find x self self x x def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return unite if self.same(x, y):
            return

         self.same(x, y) self.same self same x y return xr = self.find(x) xr self.find(x) self.find self find x yr = self.find(y) yr self.find(y) self.find self find y if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
         self.size[xr] > self.size[yr] self.size[xr] self.size self size xr self.size[yr] self.size self size yr xr, yr = yr, xr xr yr yr xr self.size[yr] = self.size[xr] + self.size[yr] self.size[yr] self.size self size yr self.size[xr] + self.size[yr] self.size[xr] self.size self size xr self.size[yr] self.size self size yr self.par[xr] = yr self.par[xr] self.par self par xr yr return self self x x y y def submit():
    n, m = map(int, input().split())
    bridge = [tuple(map(int, input().split())) for _ in range(m)]

    uf = UnionFind(n)
    curr = n * (n - 1) // 2
    ans = []
    for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


    for a in reversed(ans):
        print(a) submit 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 bridge = [tuple(map(int, input().split())) for _ in range(m)] bridge [tuple(map(int, input().split())) for _ in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n curr = n * (n - 1) // 2 curr n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 ans = [] ans [] for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


     a b reversed(bridge) reversed bridge ans.append(curr) ans.append ans append curr if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


     not uf.same(a, b) uf.same(a, b) uf.same uf same a b curr -= uf.union_size(a) * uf.union_size(b) curr uf.union_size(a) * uf.union_size(b) uf.union_size(a) uf.union_size uf union_size a uf.union_size(b) uf.union_size uf union_size b uf.unite(a, b) uf.unite uf unite a b for a in reversed(ans):
        print(a) a reversed(ans) reversed ans print(a) print a submit() submit class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

    def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

    def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return UnionFind def submit():
    n, m = map(int, input().split())
    bridge = [tuple(map(int, input().split())) for _ in range(m)]

    uf = UnionFind(n)
    curr = n * (n - 1) // 2
    ans = []
    for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


    for a in reversed(ans):
        print(a) def submit():
    n, m = map(int, input().split())
    bridge = [tuple(map(int, input().split())) for _ in range(m)]

    uf = UnionFind(n)
    curr = n * (n - 1) // 2
    ans = []
    for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


    for a in reversed(ans):
        print(a) submit


class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.size = [1 for i in range(n + 1)]

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

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

    def unite(self, x, y):
        if self.same(x, y):
            return

        xr = self.find(x)
        yr = self.find(y)
        if self.size[xr] > self.size[yr]:
            xr, yr = yr, xr    
        self.size[yr] = self.size[xr] + self.size[yr]
        self.par[xr] = yr
        return


def submit():
    n, m = map(int, input().split())
    bridge = [tuple(map(int, input().split())) for _ in range(m)]

    uf = UnionFind(n)
    curr = n * (n - 1) // 2
    ans = []
    for a, b in reversed(bridge):
        ans.append(curr)
        if not uf.same(a, b):
            curr -= uf.union_size(a) * uf.union_size(b)
            uf.unite(a, b)


    for a in reversed(ans):
        print(a)


submit()
    
        

