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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    
n,m=map(int,input().split())
uf1=UnionFind(n)
ab=[]
res=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ab.append((a,b))
for a,b in ab[::-1]:
    aa=uf1.find(a)
    bb=uf1.find(b)
    if aa==bb:
        res.append(0)
    else:
        res.append(uf1.get_size(aa)*uf1.get_size(bb))
        uf1.union(aa,bb)
ans=0
for i in range(m):
    ans+=res[m-1-i]
    print(ans) class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
     UnionFind def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.par = [i for i in range(n)] self.par self par [i for i in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 self.rank = [0 for _ in range(n)] self.rank self rank [0 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self.size = [1 for _ in range(n)] self.size self size [1 for _ in range(n)] self self n=1 n 1 def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     self.par[x] == x self.par[x] self.par self par x 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 union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

     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:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

     x != y x y if self.rank[x] < self.rank[y]:
                x, y = y, x
             self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y x, y = y, x x y y x if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
             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.par[y] = x self.par[y] self.par self par y x self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self self x x y y 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 get_size(self, x):
        x = self.find(x)
        return self.size[x]
     get_size x = self.find(x) x self.find(x) self.find self find x return self.size[x] self.size[x] self.size self size x self self x x object n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m uf1=UnionFind(n) uf1 UnionFind(n) UnionFind n ab=[] ab [] res=[] res [] for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ab.append((a,b)) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b a,b=a-1,b-1 a a-1 a 1 b b-1 b 1 ab.append((a,b)) ab.append ab append (a,b) a b for a,b in ab[::-1]:
    aa=uf1.find(a)
    bb=uf1.find(b)
    if aa==bb:
        res.append(0)
    else:
        res.append(uf1.get_size(aa)*uf1.get_size(bb))
        uf1.union(aa,bb) a b ab[::-1] ab ::-1 -1 aa=uf1.find(a) aa uf1.find(a) uf1.find uf1 find a bb=uf1.find(b) bb uf1.find(b) uf1.find uf1 find b if aa==bb:
        res.append(0)
    else:
        res.append(uf1.get_size(aa)*uf1.get_size(bb))
        uf1.union(aa,bb) aa==bb aa bb res.append(0) res.append res append 0 res.append(uf1.get_size(aa)*uf1.get_size(bb)) res.append res append uf1.get_size(aa)*uf1.get_size(bb) uf1.get_size(aa) uf1.get_size uf1 get_size aa uf1.get_size(bb) uf1.get_size uf1 get_size bb uf1.union(aa,bb) uf1.union uf1 union aa bb ans=0 ans 0 for i in range(m):
    ans+=res[m-1-i]
    print(ans) i range(m) range m ans+=res[m-1-i] ans res[m-1-i] res m-1-i m-1 m 1 i print(ans) print ans a,b=a-1,b-1 a-1 a aa=uf1.find(a) uf1.find(a) aa m=map(int,input().split()) map(int,input().split()) m ab=[] [] ab b=a-1,b-1 b-1 b b=map(int,input().split()) map(int,input().split()) b ans=0 0 ans uf1=UnionFind(n) UnionFind(n) uf1 n,m=map(int,input().split()) map(int,input().split()) n res=[] [] res ans+=res[m-1-i] res[m-1-i] ans a,b=map(int,input().split()) map(int,input().split()) a class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
     class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
     UnionFind bb=uf1.find(b) uf1.find(b) bb
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    
n,m=map(int,input().split())
uf1=UnionFind(n)
ab=[]
res=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ab.append((a,b))
for a,b in ab[::-1]:
    aa=uf1.find(a)
    bb=uf1.find(b)
    if aa==bb:
        res.append(0)
    else:
        res.append(uf1.get_size(aa)*uf1.get_size(bb))
        uf1.union(aa,bb)
ans=0
for i in range(m):
    ans+=res[m-1-i]
    print(ans)