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

parent = [i + 1 for i in range(n)]
rank = [0 for i in range(n)]
size = [1 for i in range(n)]

def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1

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

ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
ab.reverse()
ans = [0]
for i in range(m):
    a, b = ab[i][0], ab[i][1]
    num_a = size[find(a) - 1]
    num_b = size[find(b) - 1]
    unite(a, b)
    num = size[find(a) - 1]
    if num_a != num:
        ans.append(ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b))
    else:
        ans.append(ans[-1])
ans.reverse()
num = nc2(n)
for i in range(m):
    print(num - ans[i + 1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m i + 1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) i + 1 i 1 parent = [i + 1 for i in range(n)] parent [i + 1 for i in range(n)] 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 rank = [0 for i in range(n)] rank [0 for i in range(n)] 1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 1 size = [1 for i in range(n)] size [1 for i in range(n)] def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1] find if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1] parent[x - 1] == x parent[x - 1] parent x - 1 x 1 x return x x parent[x - 1] = find(parent[x - 1]) parent[x - 1] parent x - 1 x 1 find(parent[x - 1]) find parent[x - 1] parent x - 1 x 1 return parent[x - 1] parent[x - 1] parent x - 1 x 1 x x def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1 unite x = find(x) x find(x) find x y = find(y) y find(y) find y if x == y:
        return
     x == y x y return if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1 rank[x - 1] < rank[y - 1] rank[x - 1] rank x - 1 x 1 rank[y - 1] rank y - 1 y 1 parent[x - 1] = y parent[x - 1] parent x - 1 x 1 y size[y - 1] += size[x - 1] size[y - 1] size y - 1 y 1 size[x - 1] size x - 1 x 1 parent[y - 1] = x parent[y - 1] parent y - 1 y 1 x size[x - 1] += size[y - 1] size[x - 1] size x - 1 x 1 size[y - 1] size y - 1 y 1 if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1 rank[x - 1] == rank[y - 1] rank[x - 1] rank x - 1 x 1 rank[y - 1] rank y - 1 y 1 rank[x - 1] += 1 rank[x - 1] rank x - 1 x 1 1 x x y y def nc2(a):
    return a * (a - 1) // 2 nc2 return a * (a - 1) // 2 a * (a - 1) // 2 a * (a - 1) a a - 1 a 1 2 a a ab = [] ab [] for i in range(m):
    ab.append(list(map(int, input().split()))) i range(m) range m ab.append(list(map(int, input().split()))) ab.append ab append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ab.reverse() ab.reverse ab reverse ans = [0] ans [0] 0 for i in range(m):
    a, b = ab[i][0], ab[i][1]
    num_a = size[find(a) - 1]
    num_b = size[find(b) - 1]
    unite(a, b)
    num = size[find(a) - 1]
    if num_a != num:
        ans.append(ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b))
    else:
        ans.append(ans[-1]) i range(m) range m a, b = ab[i][0], ab[i][1] a ab[i][0] [i] ab i 0 b ab[i][1] [i] ab i 1 num_a = size[find(a) - 1] num_a size[find(a) - 1] size find(a) - 1 find(a) find a 1 num_b = size[find(b) - 1] num_b size[find(b) - 1] size find(b) - 1 find(b) find b 1 unite(a, b) unite a b num = size[find(a) - 1] num size[find(a) - 1] size find(a) - 1 find(a) find a 1 if num_a != num:
        ans.append(ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b))
    else:
        ans.append(ans[-1]) num_a != num num_a num ans.append(ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b)) ans.append ans append ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b) ans[-1] + nc2(num) - nc2(num_a) ans[-1] + nc2(num) ans[-1] ans -1 nc2(num) nc2 num nc2(num_a) nc2 num_a nc2(num_b) nc2 num_b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 ans.reverse() ans.reverse ans reverse num = nc2(n) num nc2(n) nc2 n for i in range(m):
    print(num - ans[i + 1]) i range(m) range m print(num - ans[i + 1]) print num - ans[i + 1] num ans[i + 1] ans i + 1 i 1 def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1] def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1] find ab = [] [] ab m = map(int, input().split()) map(int, input().split()) m num_b = size[find(b) - 1] size[find(b) - 1] num_b def nc2(a):
    return a * (a - 1) // 2 def nc2(a):
    return a * (a - 1) // 2 nc2 ans = [0] [0] ans a, b = ab[i][0], ab[i][1] ab[i][0] a num_a = size[find(a) - 1] size[find(a) - 1] num_a b = ab[i][0], ab[i][1] ab[i][1] b parent = [i + 1 for i in range(n)] [i + 1 for i in range(n)] parent rank = [0 for i in range(n)] [0 for i in range(n)] rank size = [1 for i in range(n)] [1 for i in range(n)] size def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1 def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1 unite num = nc2(n) nc2(n) num n, m = map(int, input().split()) map(int, input().split()) n num = size[find(a) - 1] size[find(a) - 1] num
n, m = map(int, input().split())

parent = [i + 1 for i in range(n)]
rank = [0 for i in range(n)]
size = [1 for i in range(n)]

def find(x):
    if parent[x - 1] == x:
        return x
    else:
        parent[x - 1] = find(parent[x - 1])
        return parent[x - 1]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x - 1] < rank[y - 1]:
        parent[x - 1] = y
        size[y - 1] += size[x - 1]
    else:
        parent[y - 1] = x
        size[x - 1] += size[y - 1]
        if rank[x - 1] == rank[y - 1]:
            rank[x - 1] += 1

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

ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))
ab.reverse()
ans = [0]
for i in range(m):
    a, b = ab[i][0], ab[i][1]
    num_a = size[find(a) - 1]
    num_b = size[find(b) - 1]
    unite(a, b)
    num = size[find(a) - 1]
    if num_a != num:
        ans.append(ans[-1] + nc2(num) - nc2(num_a) - nc2(num_b))
    else:
        ans.append(ans[-1])
ans.reverse()
num = nc2(n)
for i in range(m):
    print(num - ans[i + 1])