class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * 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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

n,m=map(int,input().split())
e=[list(map(int,input().split())) for _ in range(m)][::-1]
u=UnionFind(n)
tmp=n*(n-1)//2
ans=[]
for a,b in e:
    ans.append(tmp)
    a,b=a-1,b-1
    if u.same(a,b):
        continue
    tmp-=u.size(a)*u.size(b)
    u.union(a,b)
print(*ans[::-1],sep='\n') class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * 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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self self n 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]

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

     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 union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

     union 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.parents[x] > self.parents[y]:
            x, y = y, x

         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x, y = y, x x y y x 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 self self x x y y def size(self, x):
        return -self.parents[self.find(x)]

     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 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split e=[list(map(int,input().split())) for _ in range(m)][::-1] e [list(map(int,input().split())) for _ in range(m)][::-1] [list(map(int,input().split())) for _ in range(m)] ::-1 -1 u=UnionFind(n) u UnionFind(n) UnionFind n tmp=n*(n-1)//2 tmp n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans=[] ans [] for a,b in e:
    ans.append(tmp)
    a,b=a-1,b-1
    if u.same(a,b):
        continue
    tmp-=u.size(a)*u.size(b)
    u.union(a,b) a b e ans.append(tmp) ans.append ans append tmp a,b=a-1,b-1 a a-1 a 1 b b-1 b 1 if u.same(a,b):
        continue
     u.same(a,b) u.same u same a b continue tmp-=u.size(a)*u.size(b) tmp u.size(a)*u.size(b) u.size(a) u.size u size a u.size(b) u.size u size b u.union(a,b) u.union u union a b print(*ans[::-1],sep='\n') print *ans[::-1] ans[::-1] ans ::-1 -1 sep='\n' sep '\n' tmp=n*(n-1)//2 n*(n-1)//2 tmp m=map(int,input().split()) map(int,input().split()) m e=[list(map(int,input().split())) for _ in range(m)][::-1] [list(map(int,input().split())) for _ in range(m)][::-1] e n,m=map(int,input().split()) map(int,input().split()) n a,b=a-1,b-1 a-1 a class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * 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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * 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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind b=a-1,b-1 b-1 b u=UnionFind(n) UnionFind(n) u ans=[] [] ans tmp-=u.size(a)*u.size(b) u.size(a)*u.size(b) tmp
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * 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]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

n,m=map(int,input().split())
e=[list(map(int,input().split())) for _ in range(m)][::-1]
u=UnionFind(n)
tmp=n*(n-1)//2
ans=[]
for a,b in e:
    ans.append(tmp)
    a,b=a-1,b-1
    if u.same(a,b):
        continue
    tmp-=u.size(a)*u.size(b)
    u.union(a,b)
print(*ans[::-1],sep='\n')