def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p
def same(x, y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]
n, m = map(int, input().split())
par = [-1 for i in range(n)]
a, b = [], []
for i in range(m):
    a_, b_ = map(int, input().split())
    a.append(a_ - 1)
    b.append(b_ - 1)
ans = [0] * m
ans[-1] = (n - 1) * n // 2
for i in range(m - 1, 0, -1):
    if same(a[i], b[i]):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - size(a[i]) * size(b[i])
        unite(a[i], b[i])
print(*ans, sep="\n") 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):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p unite p = find(x) p find(x) find x q = find(y) q find(y) find y if p == q:
        return None
     p == q p q return None None if p > q:
        p,q = q,p
     p > q p q p,q = q,p p q q p par[p] += par[q] par[p] par p par[q] par q par[q] = p par[q] par q p 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 -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 par = [-1 for i in range(n)] par [-1 for i in range(n)] a, b = [], [] a [] b [] for i in range(m):
    a_, b_ = map(int, input().split())
    a.append(a_ - 1)
    b.append(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_ a.append(a_ - 1) a.append a append a_ - 1 a_ 1 b.append(b_ - 1) b.append b append b_ - 1 b_ 1 ans = [0] * m ans [0] * m [0] 0 m ans[-1] = (n - 1) * n // 2 ans[-1] ans -1 (n - 1) * n // 2 (n - 1) * n n - 1 n 1 n 2 for i in range(m - 1, 0, -1):
    if same(a[i], b[i]):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - size(a[i]) * size(b[i])
        unite(a[i], b[i]) i range(m - 1, 0, -1) range m - 1 m 1 0 -1 if same(a[i], b[i]):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - size(a[i]) * size(b[i])
        unite(a[i], b[i]) same(a[i], b[i]) same a[i] a i b[i] b i ans[i - 1] = ans[i] ans[i - 1] ans i - 1 i 1 ans[i] ans i ans[i - 1] = ans[i] - size(a[i]) * size(b[i]) ans[i - 1] ans i - 1 i 1 ans[i] - size(a[i]) * size(b[i]) ans[i] ans i size(a[i]) * size(b[i]) size(a[i]) size a[i] a i size(b[i]) size b[i] b i unite(a[i], b[i]) unite a[i] a i b[i] b i print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" def size(x):
    return -par[find(x)] def size(x):
    return -par[find(x)] size b_ = map(int, input().split()) map(int, input().split()) b_ b = [], [] [] b def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p unite n, m = map(int, input().split()) map(int, input().split()) n a, b = [], [] [] a a_, b_ = map(int, input().split()) map(int, input().split()) a_ par = [-1 for i in range(n)] [-1 for i in range(n)] par 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 m = map(int, input().split()) map(int, input().split()) m def same(x, y):
    return find(x) == find(y) def same(x, y):
    return find(x) == find(y) same ans = [0] * m [0] * m ans
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    p = find(x)
    q = find(y)
    if p == q:
        return None
    if p > q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p
def same(x, y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]
n, m = map(int, input().split())
par = [-1 for i in range(n)]
a, b = [], []
for i in range(m):
    a_, b_ = map(int, input().split())
    a.append(a_ - 1)
    b.append(b_ - 1)
ans = [0] * m
ans[-1] = (n - 1) * n // 2
for i in range(m - 1, 0, -1):
    if same(a[i], b[i]):
        ans[i - 1] = ans[i]
    else:
        ans[i - 1] = ans[i] - size(a[i]) * size(b[i])
        unite(a[i], b[i])
print(*ans, sep="\n")