class UnionFind(): # 0インデックス
    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)]
N,M = map(int,input().split())
A,B = [],[]
for _ in range(M):
    a,b = map(int,input().split())
    A.append(a-1)
    B.append(b-1)
 
cur = N *(N-1)//2
ans = [0]*(M)
 
uf = UnionFind(N)
for i in range(M-1,-1,-1):
    ans[i] = cur
    if(uf.find(A[i]) != uf.find(B[i])):
        cur -= uf.size(A[i])*uf.size(B[i])
        uf.union(A[i],B[i])
for n in ans:
    print(n) class UnionFind(): # 0インデックス
    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)] 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 N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A,B = [],[] A [] B [] for _ in range(M):
    a,b = map(int,input().split())
    A.append(a-1)
    B.append(b-1)
  _ range(M) range M a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b A.append(a-1) A.append A append a-1 a 1 B.append(b-1) B.append B append b-1 b 1 cur = N *(N-1)//2 cur N *(N-1)//2 N *(N-1) N N-1 N 1 2 ans = [0]*(M) ans [0]*(M) [0] 0 M uf = UnionFind(N) uf UnionFind(N) UnionFind N for i in range(M-1,-1,-1):
    ans[i] = cur
    if(uf.find(A[i]) != uf.find(B[i])):
        cur -= uf.size(A[i])*uf.size(B[i])
        uf.union(A[i],B[i]) i range(M-1,-1,-1) range M-1 M 1 -1 -1 ans[i] = cur ans[i] ans i cur if(uf.find(A[i]) != uf.find(B[i])):
        cur -= uf.size(A[i])*uf.size(B[i])
        uf.union(A[i],B[i]) uf.find(A[i]) != uf.find(B[i]) uf.find(A[i]) uf.find uf find A[i] A i uf.find(B[i]) uf.find uf find B[i] B i cur -= uf.size(A[i])*uf.size(B[i]) cur uf.size(A[i])*uf.size(B[i]) uf.size(A[i]) uf.size uf size A[i] A i uf.size(B[i]) uf.size uf size B[i] B i uf.union(A[i],B[i]) uf.union uf union A[i] A i B[i] B i for n in ans:
    print(n) n ans print(n) print n B = [],[] [] B a,b = map(int,input().split()) map(int,input().split()) a uf = UnionFind(N) UnionFind(N) uf A,B = [],[] [] A cur = N *(N-1)//2 N *(N-1)//2 cur N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M cur -= uf.size(A[i])*uf.size(B[i]) uf.size(A[i])*uf.size(B[i]) cur b = map(int,input().split()) map(int,input().split()) b class UnionFind(): # 0インデックス
    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)] class UnionFind(): # 0インデックス
    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)] UnionFind ans = [0]*(M) [0]*(M) ans
class UnionFind(): # 0インデックス
    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)]
N,M = map(int,input().split())
A,B = [],[]
for _ in range(M):
    a,b = map(int,input().split())
    A.append(a-1)
    B.append(b-1)
 
cur = N *(N-1)//2
ans = [0]*(M)
 
uf = UnionFind(N)
for i in range(M-1,-1,-1):
    ans[i] = cur
    if(uf.find(A[i]) != uf.find(B[i])):
        cur -= uf.size(A[i])*uf.size(B[i])
        uf.union(A[i],B[i])
for n in ans:
    print(n)