# -*- coding: utf-8 -*-
# D - Decayed Bridges
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N,M = map(int,readline().split())
#0-index
par = [-1]*N
query = []
for _ in range(M):
    x,y = map(int,readline().split())
    query.append((x-1,y-1))

ans = [N*(N-1)//2]
for i in range(M-1):
    x,y = query[-(i+1)]
    a = ans[-1]
    if same(x,y) == False:
        a = ans[-1]-size(x)*size(y)
    ans.append(a)
    if a == 0:
        break
    union(x,y)
S = len(ans)
for i in range(M-S):
    ans.append(0)

print(*ans[::-1],sep='\n') import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 find if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 par[x] < 0 par[x] par x 0 return x x par[x] = find(par[x]) par[x] par x find(par[x]) find par[x] par x return par[x] par[x] par x x x def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定 union x = find(x) x find(x) find x y = find(y) y find(y) find y if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定 x != y x y if par[x] > par[y]:
            x,y = y,x
         par[x] > par[y] par[x] par x par[y] par y x,y = y,x x y y x par[x] += par[y] par[x] par x par[y] par y par[y] = x par[y] par y x return x x y y def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def size(x):
    return -par[find(x)] size return -par[find(x)] -par[find(x)] par[find(x)] par find(x) find x x x N,M = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline split M par = [-1]*N par [-1]*N [-1] -1 N query = [] query [] for _ in range(M):
    x,y = map(int,readline().split())
    query.append((x-1,y-1)) _ range(M) range M x,y = map(int,readline().split()) x map(int,readline().split()) map int readline().split() ().split () readline split y query.append((x-1,y-1)) query.append query append (x-1,y-1) x-1 x 1 y-1 y 1 ans = [N*(N-1)//2] ans [N*(N-1)//2] N*(N-1)//2 N*(N-1) N N-1 N 1 2 for i in range(M-1):
    x,y = query[-(i+1)]
    a = ans[-1]
    if same(x,y) == False:
        a = ans[-1]-size(x)*size(y)
    ans.append(a)
    if a == 0:
        break
    union(x,y) i range(M-1) range M-1 M 1 x,y = query[-(i+1)] x query[-(i+1)] query -(i+1) i+1 i 1 y a = ans[-1] a ans[-1] ans -1 if same(x,y) == False:
        a = ans[-1]-size(x)*size(y)
     same(x,y) == False same(x,y) same x y False a = ans[-1]-size(x)*size(y) a ans[-1]-size(x)*size(y) ans[-1] ans -1 size(x)*size(y) size(x) size x size(y) size y ans.append(a) ans.append ans append a if a == 0:
        break
     a == 0 a 0 break union(x,y) union x y S = len(ans) S len(ans) len ans for i in range(M-S):
    ans.append(0) i range(M-S) range M-S M S ans.append(0) ans.append ans append 0 print(*ans[::-1],sep='\n') print *ans[::-1] ans[::-1] ans ::-1 -1 sep='\n' sep '\n' M = map(int,readline().split()) map(int,readline().split()) M readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定 def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定 union def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数 same def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合 find N,M = map(int,readline().split()) map(int,readline().split()) N y = query[-(i+1)] query[-(i+1)] y x,y = map(int,readline().split()) map(int,readline().split()) x ans = [N*(N-1)//2] [N*(N-1)//2] ans read = sys.stdin.buffer.read sys.stdin.buffer.read read query = [] [] query readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines y = map(int,readline().split()) map(int,readline().split()) y a = ans[-1] ans[-1] a a = ans[-1]-size(x)*size(y) ans[-1]-size(x)*size(y) a x,y = query[-(i+1)] query[-(i+1)] x par = [-1]*N [-1]*N par S = len(ans) len(ans) S
# -*- coding: utf-8 -*-
# D - Decayed Bridges
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y] #xにyの個数くっつける 
        par[y] = x #yをxにくっつける
        return 

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N,M = map(int,readline().split())
#0-index
par = [-1]*N
query = []
for _ in range(M):
    x,y = map(int,readline().split())
    query.append((x-1,y-1))

ans = [N*(N-1)//2]
for i in range(M-1):
    x,y = query[-(i+1)]
    a = ans[-1]
    if same(x,y) == False:
        a = ans[-1]-size(x)*size(y)
    ans.append(a)
    if a == 0:
        break
    union(x,y)
S = len(ans)
for i in range(M-S):
    ans.append(0)

print(*ans[::-1],sep='\n')