n, m = map(int, input().split())
list_ab = []
for _ in range(m):
    a, b = map(int, input().split())
    list_ab.append((a - 1, b - 1))


# Unionfind
_group = {i: i for i in range(n)}
_size = {i: 1 for i in range(n)}


def group(i):
    vertices = []
    while _group[i] != i:
        vertices.append(i)
        i = _group[i]
    for v in vertices:
        _group[v] = i
    return i


def size(i):
    return _size[group(i)]


convenience = [0]

for a, b in list_ab[::-1]:
    ga, gb = group(a), group(b)

    if ga != gb:
        convenience.append(convenience[-1] + size(ga) * size(gb))
        if ga < gb:
            _group[group(b)] = ga

            _size[ga] += _size[gb]
        else:
            _group[group(a)] = gb
            _size[gb] += _size[ga]
    else:
        convenience.append(convenience[-1])


convenience.reverse()
inconvenience = [n * (n - 1) // 2 - c for c in convenience[1:]]


for i in inconvenience:
    print(i) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list_ab = [] list_ab [] for _ in range(m):
    a, b = map(int, input().split())
    list_ab.append((a - 1, b - 1))


# Unionfind _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b list_ab.append((a - 1, b - 1)) list_ab.append list_ab append (a - 1, b - 1) a - 1 a 1 b - 1 b 1 i: i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i i _group = {i: i for i in range(n)} _group {i: i for i in range(n)} i: 1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) i 1 _size = {i: 1 for i in range(n)} _size {i: 1 for i in range(n)} def group(i):
    vertices = []
    while _group[i] != i:
        vertices.append(i)
        i = _group[i]
    for v in vertices:
        _group[v] = i
    return i group vertices = [] vertices [] while _group[i] != i:
        vertices.append(i)
        i = _group[i]
     _group[i] != i _group[i] _group i i vertices.append(i) vertices.append vertices append i i = _group[i] i _group[i] _group i for v in vertices:
        _group[v] = i
     v vertices _group[v] = i _group[v] _group v i return i i i i def size(i):
    return _size[group(i)] size return _size[group(i)] _size[group(i)] _size group(i) group i i i convenience = [0] convenience [0] 0 for a, b in list_ab[::-1]:
    ga, gb = group(a), group(b)

    if ga != gb:
        convenience.append(convenience[-1] + size(ga) * size(gb))
        if ga < gb:
            _group[group(b)] = ga

            _size[ga] += _size[gb]
        else:
            _group[group(a)] = gb
            _size[gb] += _size[ga]
    else:
        convenience.append(convenience[-1]) a b list_ab[::-1] list_ab ::-1 -1 ga, gb = group(a), group(b) ga group(a) group a gb group(b) group b if ga != gb:
        convenience.append(convenience[-1] + size(ga) * size(gb))
        if ga < gb:
            _group[group(b)] = ga

            _size[ga] += _size[gb]
        else:
            _group[group(a)] = gb
            _size[gb] += _size[ga]
    else:
        convenience.append(convenience[-1]) ga != gb ga gb convenience.append(convenience[-1] + size(ga) * size(gb)) convenience.append convenience append convenience[-1] + size(ga) * size(gb) convenience[-1] convenience -1 size(ga) * size(gb) size(ga) size ga size(gb) size gb if ga < gb:
            _group[group(b)] = ga

            _size[ga] += _size[gb]
        else:
            _group[group(a)] = gb
            _size[gb] += _size[ga]
     ga < gb ga gb _group[group(b)] = ga _group[group(b)] _group group(b) group b ga _size[ga] += _size[gb] _size[ga] _size ga _size[gb] _size gb _group[group(a)] = gb _group[group(a)] _group group(a) group a gb _size[gb] += _size[ga] _size[gb] _size gb _size[ga] _size ga convenience.append(convenience[-1]) convenience.append convenience append convenience[-1] convenience -1 convenience.reverse() convenience.reverse convenience reverse n * (n - 1) // 2 - c for c in convenience[1:] for c in convenience[1:] c convenience[1:] convenience 1: 1 for c in convenience[1:] n * (n - 1) // 2 - c n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 c inconvenience = [n * (n - 1) // 2 - c for c in convenience[1:]] inconvenience [n * (n - 1) // 2 - c for c in convenience[1:]] for i in inconvenience:
    print(i) i inconvenience print(i) print i _size = {i: 1 for i in range(n)} {i: 1 for i in range(n)} _size _group = {i: i for i in range(n)} {i: i for i in range(n)} _group inconvenience = [n * (n - 1) // 2 - c for c in convenience[1:]] [n * (n - 1) // 2 - c for c in convenience[1:]] inconvenience n, m = map(int, input().split()) map(int, input().split()) n convenience = [0] [0] convenience gb = group(a), group(b) group(b) gb b = map(int, input().split()) map(int, input().split()) b a, b = map(int, input().split()) map(int, input().split()) a list_ab = [] [] list_ab def size(i):
    return _size[group(i)] def size(i):
    return _size[group(i)] size m = map(int, input().split()) map(int, input().split()) m def group(i):
    vertices = []
    while _group[i] != i:
        vertices.append(i)
        i = _group[i]
    for v in vertices:
        _group[v] = i
    return i def group(i):
    vertices = []
    while _group[i] != i:
        vertices.append(i)
        i = _group[i]
    for v in vertices:
        _group[v] = i
    return i group ga, gb = group(a), group(b) group(a) ga
n, m = map(int, input().split())
list_ab = []
for _ in range(m):
    a, b = map(int, input().split())
    list_ab.append((a - 1, b - 1))


# Unionfind
_group = {i: i for i in range(n)}
_size = {i: 1 for i in range(n)}


def group(i):
    vertices = []
    while _group[i] != i:
        vertices.append(i)
        i = _group[i]
    for v in vertices:
        _group[v] = i
    return i


def size(i):
    return _size[group(i)]


convenience = [0]

for a, b in list_ab[::-1]:
    ga, gb = group(a), group(b)

    if ga != gb:
        convenience.append(convenience[-1] + size(ga) * size(gb))
        if ga < gb:
            _group[group(b)] = ga

            _size[ga] += _size[gb]
        else:
            _group[group(a)] = gb
            _size[gb] += _size[ga]
    else:
        convenience.append(convenience[-1])


convenience.reverse()
inconvenience = [n * (n - 1) // 2 - c for c in convenience[1:]]


for i in inconvenience:
    print(i)
