N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append((a, b))

parent = [i for i in range(N)]
height = [1] * N
size = [1] * N

def find(i):
    while i != parent[i]:
        i = parent[i]
    return i

def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i]


score = N*(N-1)//2
ans = [score]
for a, b in edges[::-1]:
    a = find(a)
    b = find(b)
    if a != b:
        score -= size[a] * size[b]
        union(a, b)
    ans.append(score)

for i in ans[len(ans)-2::-1]:
    print(i) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M edges = [] edges [] for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append((a, b)) _ range(M) range M a, b = map(lambda x: int(x)-1, input().split()) a map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split b edges.append((a, b)) edges.append edges append (a, b) a b i for i in range(N) for i in range(N) i range(N) range N for i in range(N) i parent = [i for i in range(N)] parent [i for i in range(N)] height = [1] * N height [1] * N [1] 1 N size = [1] * N size [1] * N [1] 1 N def find(i):
    while i != parent[i]:
        i = parent[i]
    return i find while i != parent[i]:
        i = parent[i]
     i != parent[i] i parent[i] parent i i = parent[i] i parent[i] parent i return i i i i def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i] union i = find(i) i find(i) find i j = find(j) j find(j) find j if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i] height[i] >= height[j] height[i] height i height[j] height j parent[j] = i parent[j] parent j i height[i] = max(height[i], height[j] + 1) height[i] height i max(height[i], height[j] + 1) max height[i] height i height[j] + 1 height[j] height j 1 size[i] += size[j] size[i] size i size[j] size j parent[i] = j parent[i] parent i j height[j] = max(height[j], height[i] + 1) height[j] height j max(height[j], height[i] + 1) max height[j] height j height[i] + 1 height[i] height i 1 size[j] += size[i] size[j] size j size[i] size i i i j j score = N*(N-1)//2 score N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [score] ans [score] score for a, b in edges[::-1]:
    a = find(a)
    b = find(b)
    if a != b:
        score -= size[a] * size[b]
        union(a, b)
    ans.append(score) a b edges[::-1] edges ::-1 -1 a = find(a) a find(a) find a b = find(b) b find(b) find b if a != b:
        score -= size[a] * size[b]
        union(a, b)
     a != b a b score -= size[a] * size[b] score size[a] * size[b] size[a] size a size[b] size b union(a, b) union a b ans.append(score) ans.append ans append score for i in ans[len(ans)-2::-1]:
    print(i) i ans[len(ans)-2::-1] ans len(ans)-2::-1 len(ans)-2 len(ans) len ans 2 -1 print(i) print i size = [1] * N [1] * N size def find(i):
    while i != parent[i]:
        i = parent[i]
    return i def find(i):
    while i != parent[i]:
        i = parent[i]
    return i find edges = [] [] edges score -= size[a] * size[b] size[a] * size[b] score score = N*(N-1)//2 N*(N-1)//2 score b = find(b) find(b) b def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i] def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i] union a = find(a) find(a) a parent = [i for i in range(N)] [i for i in range(N)] parent a, b = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) a M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N ans = [score] [score] ans height = [1] * N [1] * N height b = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) b
N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    edges.append((a, b))

parent = [i for i in range(N)]
height = [1] * N
size = [1] * N

def find(i):
    while i != parent[i]:
        i = parent[i]
    return i

def union(i, j):
    i = find(i)
    j = find(j)
    if height[i] >= height[j]:
        parent[j] = i
        height[i] = max(height[i], height[j] + 1)
        size[i] += size[j]
    else:
        parent[i] = j
        height[j] = max(height[j], height[i] + 1)
        size[j] += size[i]


score = N*(N-1)//2
ans = [score]
for a, b in edges[::-1]:
    a = find(a)
    b = find(b)
    if a != b:
        score -= size[a] * size[b]
        union(a, b)
    ans.append(score)

for i in ans[len(ans)-2::-1]:
    print(i)