import sys
input=sys.stdin.readline
from math import factorial
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
def same(x,y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]

n,m=map(int,input().split())
par = [-1]*n
lst=[]
for i in range(m):
    a,b=map(int,input().split())
    lst.append([a-1,b-1])
lst.reverse()
anslst=[(factorial(n)//(2*factorial(n-2)))]
for i in range(m-1):
    a,b=lst[i]
    if same(a,b):
        anslst.append(anslst[-1])
    else:
        c=size(a)*size(b)
        anslst.append(anslst[-1]-c)
        union(a,b)
anslst.reverse()
for i in anslst:
    print(i) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from math import factorial 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 union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True union x = find(x) x find(x) find x y = find(y) y find(y) find y if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True 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 same(x,y):
    return find(x) == find(y) 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,input().split()) n map(int,input().split()) map int input().split() ().split () input split m par = [-1]*n par [-1]*n [-1] -1 n lst=[] lst [] for i in range(m):
    a,b=map(int,input().split())
    lst.append([a-1,b-1]) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b lst.append([a-1,b-1]) lst.append lst append [a-1,b-1] a-1 a 1 b-1 b 1 lst.reverse() lst.reverse lst reverse anslst=[(factorial(n)//(2*factorial(n-2)))] anslst [(factorial(n)//(2*factorial(n-2)))] factorial(n)//(2*factorial(n-2)) factorial(n) factorial n 2*factorial(n-2) 2 factorial(n-2) factorial n-2 n 2 for i in range(m-1):
    a,b=lst[i]
    if same(a,b):
        anslst.append(anslst[-1])
    else:
        c=size(a)*size(b)
        anslst.append(anslst[-1]-c)
        union(a,b) i range(m-1) range m-1 m 1 a,b=lst[i] a lst[i] lst i b if same(a,b):
        anslst.append(anslst[-1])
    else:
        c=size(a)*size(b)
        anslst.append(anslst[-1]-c)
        union(a,b) same(a,b) same a b anslst.append(anslst[-1]) anslst.append anslst append anslst[-1] anslst -1 c=size(a)*size(b) c size(a)*size(b) size(a) size a size(b) size b anslst.append(anslst[-1]-c) anslst.append anslst append anslst[-1]-c anslst[-1] anslst -1 c union(a,b) union a b anslst.reverse() anslst.reverse anslst reverse for i in anslst:
    print(i) i anslst print(i) print i def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size def same(x,y):
    return find(x) == find(y) def same(x,y):
    return find(x) == find(y) same b=map(int,input().split()) map(int,input().split()) b anslst=[(factorial(n)//(2*factorial(n-2)))] [(factorial(n)//(2*factorial(n-2)))] anslst input=sys.stdin.readline sys.stdin.readline input 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 n,m=map(int,input().split()) map(int,input().split()) n c=size(a)*size(b) size(a)*size(b) c par = [-1]*n [-1]*n par lst=[] [] lst a,b=map(int,input().split()) map(int,input().split()) a a,b=lst[i] lst[i] a m=map(int,input().split()) map(int,input().split()) m def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True union b=lst[i] lst[i] b
import sys
input=sys.stdin.readline
from math import factorial
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:   #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
def same(x,y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]

n,m=map(int,input().split())
par = [-1]*n
lst=[]
for i in range(m):
    a,b=map(int,input().split())
    lst.append([a-1,b-1])
lst.reverse()
anslst=[(factorial(n)//(2*factorial(n-2)))]
for i in range(m-1):
    a,b=lst[i]
    if same(a,b):
        anslst.append(anslst[-1])
    else:
        c=size(a)*size(b)
        anslst.append(anslst[-1]-c)
        union(a,b)
anslst.reverse()
for i in anslst:
    print(i)