def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
    
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    
    root[x] += root[y]
    root[y] = x
    
def size(x):
    return -root[find(x)]

def same(x,y):
    return find(x) == find(y)

def member(x):
    rt = find(x)
    return [i for i in range(n) if find(i) == rt]

def roots():
    return [i for i, x in enumerate(root) if x < 0]

def member_count(x):
    return len(roots())

def all_group_members():
    return {r: member(r) for r in roots()}

n , m = map(int,input().split())
root = [-1 for i in range(n)]
ans = [0 for i in range(m)]
ans[m-1] = n*(n-1)//2
hasi = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)]
for i in reversed(range(m-1)):
    a , b = hasi[i+1]
    if same(a,b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - size(a)*size(b)
        unite(a,b)
for i in range(m):
    print(ans[i]) def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
     find if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
     root[n] < 0 root[n] root n 0 return n n root[n] = find(root[n]) root[n] root n find(root[n]) find root[n] root n return root[n] root[n] root n n n def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    
    root[x] += root[y]
    root[y] = x
     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 root[x] > root[y]:
        x, y = y, x
    
     root[x] > root[y] root[x] root x root[y] root y x, y = y, x x y y x root[x] += root[y] root[x] root x root[y] root y root[y] = x root[y] root y x x x y y def size(x):
    return -root[find(x)] size return -root[find(x)] -root[find(x)] root[find(x)] root find(x) find x x x def same(x,y):
    return find(x) == find(y) same return find(x) == find(y) find(x) == find(y) find(x) find x find(y) find y x x y y def member(x):
    rt = find(x)
    return [i for i in range(n) if find(i) == rt] member rt = find(x) rt find(x) find x i for i in range(n) if find(i) == rt for i in range(n) if find(i) == rt i range(n) range n find(i) == rt find(i) find i rt if find(i) == rt i return [i for i in range(n) if find(i) == rt] [i for i in range(n) if find(i) == rt] x x def roots():
    return [i for i, x in enumerate(root) if x < 0] roots i for i, x in enumerate(root) if x < 0 for i, x in enumerate(root) if x < 0 i x enumerate(root) enumerate root x < 0 x 0 if x < 0 i return [i for i, x in enumerate(root) if x < 0] [i for i, x in enumerate(root) if x < 0] def member_count(x):
    return len(roots()) member_count return len(roots()) len(roots()) len roots() roots x x def all_group_members():
    return {r: member(r) for r in roots()} all_group_members r: member(r) for r in roots() for r in roots() r roots() roots for r in roots() r member(r) member r return {r: member(r) for r in roots()} {r: member(r) for r in roots()} n , m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 root = [-1 for i in range(n)] root [-1 for i in range(n)] 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 ans = [0 for i in range(m)] ans [0 for i in range(m)] ans[m-1] = n*(n-1)//2 ans[m-1] ans m-1 m 1 n*(n-1)//2 n*(n-1) n n-1 n 1 2 tuple(map(lambda x:int(x)-1,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) tuple(map(lambda x:int(x)-1,input().split())) tuple 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 hasi = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)] hasi [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)] for i in reversed(range(m-1)):
    a , b = hasi[i+1]
    if same(a,b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - size(a)*size(b)
        unite(a,b) i reversed(range(m-1)) reversed range(m-1) range m-1 m 1 a , b = hasi[i+1] a hasi[i+1] hasi i+1 i 1 b if same(a,b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - size(a)*size(b)
        unite(a,b) same(a,b) same a b ans[i] = ans[i+1] ans[i] ans i ans[i+1] ans i+1 i 1 ans[i] = ans[i+1] - size(a)*size(b) ans[i] ans i ans[i+1] - size(a)*size(b) ans[i+1] ans i+1 i 1 size(a)*size(b) size(a) size a size(b) size b unite(a,b) unite a b for i in range(m):
    print(ans[i]) i range(m) range m print(ans[i]) print ans[i] ans i a , b = hasi[i+1] hasi[i+1] a def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    
    root[x] += root[y]
    root[y] = x
     def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    
    root[x] += root[y]
    root[y] = x
     unite ans = [0 for i in range(m)] [0 for i in range(m)] ans def member(x):
    rt = find(x)
    return [i for i in range(n) if find(i) == rt] def member(x):
    rt = find(x)
    return [i for i in range(n) if find(i) == rt] member n , m = map(int,input().split()) map(int,input().split()) n def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
     def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
     find def roots():
    return [i for i, x in enumerate(root) if x < 0] def roots():
    return [i for i, x in enumerate(root) if x < 0] roots hasi = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)] [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)] hasi def size(x):
    return -root[find(x)] def size(x):
    return -root[find(x)] size root = [-1 for i in range(n)] [-1 for i in range(n)] root def same(x,y):
    return find(x) == find(y) def same(x,y):
    return find(x) == find(y) same m = map(int,input().split()) map(int,input().split()) m b = hasi[i+1] hasi[i+1] b def member_count(x):
    return len(roots()) def member_count(x):
    return len(roots()) member_count def all_group_members():
    return {r: member(r) for r in roots()} def all_group_members():
    return {r: member(r) for r in roots()} all_group_members
def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]
    
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if root[x] > root[y]:
        x, y = y, x
    
    root[x] += root[y]
    root[y] = x
    
def size(x):
    return -root[find(x)]

def same(x,y):
    return find(x) == find(y)

def member(x):
    rt = find(x)
    return [i for i in range(n) if find(i) == rt]

def roots():
    return [i for i, x in enumerate(root) if x < 0]

def member_count(x):
    return len(roots())

def all_group_members():
    return {r: member(r) for r in roots()}

n , m = map(int,input().split())
root = [-1 for i in range(n)]
ans = [0 for i in range(m)]
ans[m-1] = n*(n-1)//2
hasi = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(m)]
for i in reversed(range(m-1)):
    a , b = hasi[i+1]
    if same(a,b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - size(a)*size(b)
        unite(a,b)
for i in range(m):
    print(ans[i])