def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]

n, m = map(int, input().split())
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])
par = [-1]*n
ans = n*(n-1)//2
ansl = [ans]
for a, b in ab[::-1]:
    if find(a)!=find(b):
        ans -= size(a)*size(b)
    unite(a, b)
    ansl.append(ans)
for i in range(m-1, -1, -1):
    print(ansl[i]) def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] 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 unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True unite x, y = find(x), find(y) x find(x) find x y find(y) find y if x == y:
        return False
    
     x == y x y return False False 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 True True 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, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ab = [] ab [] for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a-1, 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 ab.append([a-1, b-1]) ab.append ab append [a-1, b-1] a-1 a 1 b-1 b 1 par = [-1]*n par [-1]*n [-1] -1 n ans = n*(n-1)//2 ans n*(n-1)//2 n*(n-1) n n-1 n 1 2 ansl = [ans] ansl [ans] ans for a, b in ab[::-1]:
    if find(a)!=find(b):
        ans -= size(a)*size(b)
    unite(a, b)
    ansl.append(ans) a b ab[::-1] ab ::-1 -1 if find(a)!=find(b):
        ans -= size(a)*size(b)
     find(a)!=find(b) find(a) find a find(b) find b ans -= size(a)*size(b) ans size(a)*size(b) size(a) size a size(b) size b unite(a, b) unite a b ansl.append(ans) ansl.append ansl append ans for i in range(m-1, -1, -1):
    print(ansl[i]) i range(m-1, -1, -1) range m-1 m 1 -1 -1 print(ansl[i]) print ansl[i] ansl i par = [-1]*n [-1]*n par def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True unite def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size n, m = map(int, input().split()) map(int, input().split()) n a, b = map(int, input().split()) map(int, input().split()) a ab = [] [] ab ans = n*(n-1)//2 n*(n-1)//2 ans m = map(int, input().split()) map(int, input().split()) m b = map(int, input().split()) map(int, input().split()) b ans -= size(a)*size(b) size(a)*size(b) ans def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find ansl = [ans] [ans] ansl
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]

n, m = map(int, input().split())
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])
par = [-1]*n
ans = n*(n-1)//2
ansl = [ans]
for a, b in ab[::-1]:
    if find(a)!=find(b):
        ans -= size(a)*size(b)
    unite(a, b)
    ansl.append(ans)
for i in range(m-1, -1, -1):
    print(ansl[i])