N, M = map(int, input().split())

# 最初は全て繋がっているが、1本ずつ崩落していく。
# uniteし続けて、最終的に親が違うものは分離しているとみなせる？


parents = None


def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x]


count = 0


def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x


def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y)


def size(x):
    return -parents[root(x)]


es = []
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    es.append((a, b))


parents = [-1] * N
ans = [0 for _ in range(M + 1)]
ans[M] = N * (N - 1) // 2
for i, e in enumerate(es[::-1]):
    # print('===========')
    a, b = e
    if root(a) != root(b):
        # print(size(a), size(b))
        x, y = size(a), size(b)
    else:
        x, y = 0, 0
    unit(a, b)
    ans[M - 1 - i] = ans[M - i] - (x * y)
    # print(parents)


# print(ans)
for num in ans[1:]:
    print(num) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M parents = None parents None def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x] root if parents[x] < 0:
        return x
     parents[x] < 0 parents[x] parents x 0 return x x if parents[x] == x:
        return x
     parents[x] == x parents[x] parents x x return x x parents[x] = root(parents[x]) parents[x] parents x root(parents[x]) root parents[x] parents x return parents[x] parents[x] parents x x x count = 0 count 0 def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x unit root_x = root(x) root_x root(x) root x root_y = root(y) root_y root(y) root y if root_x == root_y:
        return

     root_x == root_y root_x root_y return if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
     parents[root_x] > parents[root_y] parents[root_x] parents root_x parents[root_y] parents root_y root_x, root_y = root_y, root_x root_x root_y root_y root_x parents[root_x] += parents[root_y] parents[root_x] parents root_x parents[root_y] parents root_y parents[root_y] = root_x parents[root_y] parents root_y root_x x x y y def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y) same root_x = root(x) root_x root(x) root x root_y = root(y) root_y root(y) root y return (root_x == root_y) root_x == root_y root_x root_y x x y y def size(x):
    return -parents[root(x)] size return -parents[root(x)] -parents[root(x)] parents[root(x)] parents root(x) root x x x es = [] es [] for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    es.append((a, b)) 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, b = a - 1, b - 1 a a - 1 a 1 b b - 1 b 1 es.append((a, b)) es.append es append (a, b) a b parents = [-1] * N parents [-1] * N [-1] -1 N 0 for _ in range(M + 1) for _ in range(M + 1) _ range(M + 1) range M + 1 M 1 for _ in range(M + 1) 0 ans = [0 for _ in range(M + 1)] ans [0 for _ in range(M + 1)] ans[M] = N * (N - 1) // 2 ans[M] ans M N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 for i, e in enumerate(es[::-1]):
    # print('===========')
    a, b = e
    if root(a) != root(b):
        # print(size(a), size(b))
        x, y = size(a), size(b)
    else:
        x, y = 0, 0
    unit(a, b)
    ans[M - 1 - i] = ans[M - i] - (x * y)
    # print(parents)


# print(ans) i e enumerate(es[::-1]) enumerate es[::-1] es ::-1 -1 a, b = e a e b if root(a) != root(b):
        # print(size(a), size(b))
        x, y = size(a), size(b)
    else:
        x, y = 0, 0
     root(a) != root(b) root(a) root a root(b) root b x, y = size(a), size(b) x size(a) size a y size(b) size b x, y = 0, 0 x 0 y 0 unit(a, b) unit a b ans[M - 1 - i] = ans[M - i] - (x * y) ans[M - 1 - i] ans M - 1 - i M - 1 M 1 i ans[M - i] - (x * y) ans[M - i] ans M - i M i x * y x y for num in ans[1:]:
    print(num) num ans[1:] ans 1: 1 print(num) print num count = 0 0 count a, b = map(int, input().split()) map(int, input().split()) a M = map(int, input().split()) map(int, input().split()) M parents = [-1] * N [-1] * N parents N, M = map(int, input().split()) map(int, input().split()) N b = e e b a, b = a - 1, b - 1 a - 1 a es = [] [] es parents = None None parents ans = [0 for _ in range(M + 1)] [0 for _ in range(M + 1)] ans x, y = 0, 0 0 x y = 0, 0 0 y b = map(int, input().split()) map(int, input().split()) b y = size(a), size(b) size(b) y def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y) def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y) same x, y = size(a), size(b) size(a) x b = a - 1, b - 1 b - 1 b def size(x):
    return -parents[root(x)] def size(x):
    return -parents[root(x)] size a, b = e e a def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x unit def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x] def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x] root
N, M = map(int, input().split())

# 最初は全て繋がっているが、1本ずつ崩落していく。
# uniteし続けて、最終的に親が違うものは分離しているとみなせる？


parents = None


def root(x):
    if parents[x] < 0:
        return x
    if parents[x] == x:
        return x
    parents[x] = root(parents[x])
    return parents[x]


count = 0


def unit(x, y):
    root_x = root(x)
    root_y = root(y)
    if root_x == root_y:
        return

    if parents[root_x] > parents[root_y]:
        root_x, root_y = root_y, root_x
    parents[root_x] += parents[root_y]
    parents[root_y] = root_x


def same(x, y):
    root_x = root(x)
    root_y = root(y)
    return (root_x == root_y)


def size(x):
    return -parents[root(x)]


es = []
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    es.append((a, b))


parents = [-1] * N
ans = [0 for _ in range(M + 1)]
ans[M] = N * (N - 1) // 2
for i, e in enumerate(es[::-1]):
    # print('===========')
    a, b = e
    if root(a) != root(b):
        # print(size(a), size(b))
        x, y = size(a), size(b)
    else:
        x, y = 0, 0
    unit(a, b)
    ans[M - 1 - i] = ans[M - i] - (x * y)
    # print(parents)


# print(ans)
for num in ans[1:]:
    print(num)
