n, m = map(int, input().split())

par = [-1] * (n + 1)


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


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


def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True


def is_same(x, y):
    return find(x) == find(y)


def calc(a):
    return a * (a - 1) // 2


goukei = calc(n)
ans = [-1] * (m + 1)
ans[-1] = calc(n)
cnt = 0
AB = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    a, b = AB[i]
    if is_same(a, b):
        ans[i] = goukei - cnt
    else:
        A = size(a)
        B = size(b)
        cnt += calc(A + B) - calc(A) - calc(B)
        unite(a, b)
        ans[i] = goukei - cnt
print(*ans[1::], sep="\n") n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m par = [-1] * (n + 1) par [-1] * (n + 1) [-1] -1 n + 1 n 1 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 size(x):
    X = find(x)
    return -par[X] size X = find(x) X find(x) find x return -par[X] -par[X] par[X] par X x x def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True unite if find(x) == find(y):
        return False
     find(x) == find(y) find(x) find x find(y) find y return False False X = find(x) X find(x) find x Y = find(y) Y find(y) find y if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
     size(X) < size(Y) size(X) size X size(Y) size Y x, y = y, x x y y x X = find(x) X find(x) find x Y = find(y) Y find(y) find y 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 is_same(x, y):
    return find(x) == find(y) is_same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def calc(a):
    return a * (a - 1) // 2 calc return a * (a - 1) // 2 a * (a - 1) // 2 a * (a - 1) a a - 1 a 1 2 a a goukei = calc(n) goukei calc(n) calc n ans = [-1] * (m + 1) ans [-1] * (m + 1) [-1] -1 m + 1 m 1 ans[-1] = calc(n) ans[-1] ans -1 calc(n) calc n cnt = 0 cnt 0 list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split AB = [list(map(int, input().split())) for _ in range(m)] AB [list(map(int, input().split())) for _ in range(m)] for i in range(m - 1, -1, -1):
    a, b = AB[i]
    if is_same(a, b):
        ans[i] = goukei - cnt
    else:
        A = size(a)
        B = size(b)
        cnt += calc(A + B) - calc(A) - calc(B)
        unite(a, b)
        ans[i] = goukei - cnt i range(m - 1, -1, -1) range m - 1 m 1 -1 -1 a, b = AB[i] a AB[i] AB i b if is_same(a, b):
        ans[i] = goukei - cnt
    else:
        A = size(a)
        B = size(b)
        cnt += calc(A + B) - calc(A) - calc(B)
        unite(a, b)
        ans[i] = goukei - cnt is_same(a, b) is_same a b ans[i] = goukei - cnt ans[i] ans i goukei - cnt goukei cnt A = size(a) A size(a) size a B = size(b) B size(b) size b cnt += calc(A + B) - calc(A) - calc(B) cnt calc(A + B) - calc(A) - calc(B) calc(A + B) - calc(A) calc(A + B) calc A + B A B calc(A) calc A calc(B) calc B unite(a, b) unite a b ans[i] = goukei - cnt ans[i] ans i goukei - cnt goukei cnt print(*ans[1::], sep="\n") print *ans[1::] ans[1::] ans 1:: 1 sep="\n" sep "\n" a, b = AB[i] AB[i] a def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True unite ans = [-1] * (m + 1) [-1] * (m + 1) ans cnt = 0 0 cnt cnt += calc(A + B) - calc(A) - calc(B) calc(A + B) - calc(A) - calc(B) cnt n, m = map(int, input().split()) map(int, input().split()) n def is_same(x, y):
    return find(x) == find(y) def is_same(x, y):
    return find(x) == find(y) is_same par = [-1] * (n + 1) [-1] * (n + 1) 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 def size(x):
    X = find(x)
    return -par[X] def size(x):
    X = find(x)
    return -par[X] size A = size(a) size(a) A m = map(int, input().split()) map(int, input().split()) m AB = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] AB def calc(a):
    return a * (a - 1) // 2 def calc(a):
    return a * (a - 1) // 2 calc goukei = calc(n) calc(n) goukei b = AB[i] AB[i] b B = size(b) size(b) B
n, m = map(int, input().split())

par = [-1] * (n + 1)


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


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


def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True


def is_same(x, y):
    return find(x) == find(y)


def calc(a):
    return a * (a - 1) // 2


goukei = calc(n)
ans = [-1] * (m + 1)
ans[-1] = calc(n)
cnt = 0
AB = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    a, b = AB[i]
    if is_same(a, b):
        ans[i] = goukei - cnt
    else:
        A = size(a)
        B = size(b)
        cnt += calc(A + B) - calc(A) - calc(B)
        unite(a, b)
        ans[i] = goukei - cnt
print(*ans[1::], sep="\n")
