def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i])

def size(a):
    return -par[root(a)]

def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True

n,m = map(int,input().split())
bridge = []
for i in range(m):
    bridge.append([int(j)-1 for j in input().split()])
ans = [n*(n-1)//2]
par = [-1 for _ in range(n)]

for a,b in bridge[::-1]:
    if root(a) == root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - size(a) * size(b))
        union(a,b)
ans = ans[::-1]
for i in ans[1:]:
    print(i) def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i]) root if par[i] < 0:
        return i
    else:
        return root(par[i]) par[i] < 0 par[i] par i 0 return i i return root(par[i]) root(par[i]) root par[i] par i i i def size(a):
    return -par[root(a)] size return -par[root(a)] -par[root(a)] par[root(a)] par root(a) root a a a def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True union a = root(a) a root(a) root a b = root(b) b root(b) root b if a == b:#親が等しい
        return False
     a == b a b return False False if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
     size(a) < size(b) size(a) size a size(b) size b a,b = b,a a b b a par[a] += par[b] par[a] par a par[b] par b par[b] = a par[b] par b a return True True a a b b n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m bridge = [] bridge [] for i in range(m):
    bridge.append([int(j)-1 for j in input().split()]) i range(m) range m int(j)-1 for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j)-1 int(j) int j 1 bridge.append([int(j)-1 for j in input().split()]) bridge.append bridge append [int(j)-1 for j in input().split()] ans = [n*(n-1)//2] ans [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 -1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) -1 par = [-1 for _ in range(n)] par [-1 for _ in range(n)] for a,b in bridge[::-1]:
    if root(a) == root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - size(a) * size(b))
        union(a,b) a b bridge[::-1] bridge ::-1 -1 if root(a) == root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - size(a) * size(b))
        union(a,b) root(a) == root(b) root(a) root a root(b) root b ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 ans.append(ans[-1] - size(a) * size(b)) ans.append ans append ans[-1] - size(a) * size(b) ans[-1] ans -1 size(a) * size(b) size(a) size a size(b) size b union(a,b) union a b ans = ans[::-1] ans ans[::-1] ans ::-1 -1 for i in ans[1:]:
    print(i) i ans[1:] ans 1: 1 print(i) print i ans = ans[::-1] ans[::-1] ans ans = [n*(n-1)//2] [n*(n-1)//2] ans def size(a):
    return -par[root(a)] def size(a):
    return -par[root(a)] size n,m = map(int,input().split()) map(int,input().split()) n def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i]) def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i]) root bridge = [] [] bridge m = map(int,input().split()) map(int,input().split()) m par = [-1 for _ in range(n)] [-1 for _ in range(n)] par def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True union
def root(i):
    if par[i] < 0:
        return i
    else:
        return root(par[i])

def size(a):
    return -par[root(a)]

def union(a,b):
    a = root(a)
    b = root(b)
    if a == b:#親が等しい
        return False
    if size(a) < size(b):#サイズが大きい方に繋げる
        a,b = b,a
    par[a] += par[b]
    par[b] = a
    return True

n,m = map(int,input().split())
bridge = []
for i in range(m):
    bridge.append([int(j)-1 for j in input().split()])
ans = [n*(n-1)//2]
par = [-1 for _ in range(n)]

for a,b in bridge[::-1]:
    if root(a) == root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - size(a) * size(b))
        union(a,b)
ans = ans[::-1]
for i in ans[1:]:
    print(i)