# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [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]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
    def check(self, x, y):
        return self.find(x) == self.find(y)
    def cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N+1)
cnt = N*(N-1)//2
Ans = [0]*(M+1)
Ans[-1] = cnt
for i in range(M):
    a,b = AB[M-1-i]
    # 元々連結な場合
    if uf.check(a,b):
        Ans[M-1-i] = cnt
    # 元々連結ではない場合
    else:
        cnt -= uf.cnt(a)*uf.cnt(b)
        Ans[M-1-i] = cnt
    uf.unite(a,b)

for i in range(1,M+1):
    print(Ans[i]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [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]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
    def check(self, x, y):
        return self.find(x) == self.find(y)
    def cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# ------------------------------------------------------------- UnionFind def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [1]*(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)] self.size = [1]*(n+1) self.size self size [1]*(n+1) [1] 1 n+1 n 1 self self n 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]
     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 unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
     unite 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
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
     x==y x y return if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
     self.size[x] < self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self.par[x] = y self.par[x] self.par self par x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x 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 check(self, x, y):
        return self.find(x) == self.find(y)
     check 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 cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# ------------------------------------------------------------- cnt 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 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)] uf = UnionFind(N+1) uf UnionFind(N+1) UnionFind N+1 N 1 cnt = N*(N-1)//2 cnt N*(N-1)//2 N*(N-1) N N-1 N 1 2 Ans = [0]*(M+1) Ans [0]*(M+1) [0] 0 M+1 M 1 Ans[-1] = cnt Ans[-1] Ans -1 cnt for i in range(M):
    a,b = AB[M-1-i]
    # 元々連結な場合
    if uf.check(a,b):
        Ans[M-1-i] = cnt
    # 元々連結ではない場合
    else:
        cnt -= uf.cnt(a)*uf.cnt(b)
        Ans[M-1-i] = cnt
    uf.unite(a,b) i range(M) range M a,b = AB[M-1-i] a AB[M-1-i] AB M-1-i M-1 M 1 i b if uf.check(a,b):
        Ans[M-1-i] = cnt
    # 元々連結ではない場合
    else:
        cnt -= uf.cnt(a)*uf.cnt(b)
        Ans[M-1-i] = cnt
     uf.check(a,b) uf.check uf check a b Ans[M-1-i] = cnt Ans[M-1-i] Ans M-1-i M-1 M 1 i cnt cnt -= uf.cnt(a)*uf.cnt(b) cnt uf.cnt(a)*uf.cnt(b) uf.cnt(a) uf.cnt uf cnt a uf.cnt(b) uf.cnt uf cnt b Ans[M-1-i] = cnt Ans[M-1-i] Ans M-1-i M-1 M 1 i cnt uf.unite(a,b) uf.unite uf unite a b for i in range(1,M+1):
    print(Ans[i]) i range(1,M+1) range 1 M+1 M 1 print(Ans[i]) print Ans[i] Ans i input = sys.stdin.readline sys.stdin.readline input N,M = map(int,input().split()) map(int,input().split()) N Ans = [0]*(M+1) [0]*(M+1) Ans a,b = AB[M-1-i] AB[M-1-i] a M = map(int,input().split()) map(int,input().split()) M b = AB[M-1-i] AB[M-1-i] b AB = [tuple(map(int,input().split())) for _ in range(M)] [tuple(map(int,input().split())) for _ in range(M)] AB cnt -= uf.cnt(a)*uf.cnt(b) uf.cnt(a)*uf.cnt(b) cnt cnt = N*(N-1)//2 N*(N-1)//2 cnt class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [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]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
    def check(self, x, y):
        return self.find(x) == self.find(y)
    def cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# ------------------------------------------------------------- class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [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]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
    def check(self, x, y):
        return self.find(x) == self.find(y)
    def cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# ------------------------------------------------------------- UnionFind uf = UnionFind(N+1) UnionFind(N+1) uf
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [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]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        else:
            if self.size[x] < self.size[y]:
                self.par[x] = y
                self.size[y] += self.size[x]
            else:
                self.par[y] = x
                self.size[x] += self.size[y]
    def check(self, x, y):
        return self.find(x) == self.find(y)
    def cnt(self, x):
        return self.size[self.find(x)]

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N+1)
cnt = N*(N-1)//2
Ans = [0]*(M+1)
Ans[-1] = cnt
for i in range(M):
    a,b = AB[M-1-i]
    # 元々連結な場合
    if uf.check(a,b):
        Ans[M-1-i] = cnt
    # 元々連結ではない場合
    else:
        cnt -= uf.cnt(a)*uf.cnt(b)
        Ans[M-1-i] = cnt
    uf.unite(a,b)

for i in range(1,M+1):
    print(Ans[i])