def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
def union(x,y):
    rt1 = find(x)
    rt2 = find(y)
    if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1]
N,M = map(int,input().split())
E = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,1] for i in range(1,N+1)}
RT = {i:1 for i in range(1,N+1)}
cnt = 0
ans = (N*(N-1))//2
A = []
A.append(ans)
for i in range(M-1,-1,-1):
    a,b = E[i]
    rt1 = find(a)
    rt2 = find(b)
    if rt1==rt2:
        A.append(ans)
    else:
        x = T[rt1][1]
        y = T[rt2][1]
        ans += (x*(x-1))//2+(y*(y-1))//2
        union(a,b)
        rt = find(a)
        z = T[rt][1]
        ans -= (z*(z-1))//2
        A.append(ans)
A = A[::-1]
for i in range(1,M+1):
    print(A[i]) def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x find while x!=T[x][0]:
        x = T[x][0]
     x!=T[x][0] x T[x][0] [x] T x 0 x = T[x][0] x T[x][0] [x] T x 0 return x x x x def union(x,y):
    rt1 = find(x)
    rt2 = find(y)
    if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1] union rt1 = find(x) rt1 find(x) find x rt2 = find(y) rt2 find(y) find y if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1] T[rt1][1]>=T[rt2][1] T[rt1][1] [rt1] T rt1 1 T[rt2][1] [rt2] T rt2 1 T[rt2][0] = rt1 T[rt2][0] [rt2] T rt2 0 rt1 T[rt1][1] += T[rt2][1] T[rt1][1] [rt1] T rt1 1 T[rt2][1] [rt2] T rt2 1 T[rt1][0] = rt2 T[rt1][0] [rt1] T rt1 0 rt2 T[rt2][1] += T[rt1][1] T[rt2][1] [rt2] T rt2 1 T[rt1][1] [rt1] T rt1 1 x x y y N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M list(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split E = [list(map(int,input().split())) for _ in range(M)] E [list(map(int,input().split())) for _ in range(M)] i:[i,1] for i in range(1,N+1) for i in range(1,N+1) i range(1,N+1) range 1 N+1 N 1 for i in range(1,N+1) i [i,1] i 1 T = {i:[i,1] for i in range(1,N+1)} T {i:[i,1] for i in range(1,N+1)} i:1 for i in range(1,N+1) for i in range(1,N+1) i range(1,N+1) range 1 N+1 N 1 for i in range(1,N+1) i 1 RT = {i:1 for i in range(1,N+1)} RT {i:1 for i in range(1,N+1)} cnt = 0 cnt 0 ans = (N*(N-1))//2 ans (N*(N-1))//2 N*(N-1) N N-1 N 1 2 A = [] A [] A.append(ans) A.append A append ans for i in range(M-1,-1,-1):
    a,b = E[i]
    rt1 = find(a)
    rt2 = find(b)
    if rt1==rt2:
        A.append(ans)
    else:
        x = T[rt1][1]
        y = T[rt2][1]
        ans += (x*(x-1))//2+(y*(y-1))//2
        union(a,b)
        rt = find(a)
        z = T[rt][1]
        ans -= (z*(z-1))//2
        A.append(ans) i range(M-1,-1,-1) range M-1 M 1 -1 -1 a,b = E[i] a E[i] E i b rt1 = find(a) rt1 find(a) find a rt2 = find(b) rt2 find(b) find b if rt1==rt2:
        A.append(ans)
    else:
        x = T[rt1][1]
        y = T[rt2][1]
        ans += (x*(x-1))//2+(y*(y-1))//2
        union(a,b)
        rt = find(a)
        z = T[rt][1]
        ans -= (z*(z-1))//2
        A.append(ans) rt1==rt2 rt1 rt2 A.append(ans) A.append A append ans x = T[rt1][1] x T[rt1][1] [rt1] T rt1 1 y = T[rt2][1] y T[rt2][1] [rt2] T rt2 1 ans += (x*(x-1))//2+(y*(y-1))//2 ans (x*(x-1))//2+(y*(y-1))//2 (x*(x-1))//2 x*(x-1) x x-1 x 1 2 (y*(y-1))//2 y*(y-1) y y-1 y 1 2 union(a,b) union a b rt = find(a) rt find(a) find a z = T[rt][1] z T[rt][1] [rt] T rt 1 ans -= (z*(z-1))//2 ans (z*(z-1))//2 z*(z-1) z z-1 z 1 2 A.append(ans) A.append A append ans A = A[::-1] A A[::-1] A ::-1 -1 for i in range(1,M+1):
    print(A[i]) i range(1,M+1) range 1 M+1 M 1 print(A[i]) print A[i] A i z = T[rt][1] T[rt][1] z ans += (x*(x-1))//2+(y*(y-1))//2 (x*(x-1))//2+(y*(y-1))//2 ans M = map(int,input().split()) map(int,input().split()) M RT = {i:1 for i in range(1,N+1)} {i:1 for i in range(1,N+1)} RT A = [] [] A cnt = 0 0 cnt E = [list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] E rt1 = find(a) find(a) rt1 N,M = map(int,input().split()) map(int,input().split()) N x = T[rt1][1] T[rt1][1] x a,b = E[i] E[i] a rt2 = find(b) find(b) rt2 T = {i:[i,1] for i in range(1,N+1)} {i:[i,1] for i in range(1,N+1)} T b = E[i] E[i] b rt = find(a) find(a) rt A = A[::-1] A[::-1] A def union(x,y):
    rt1 = find(x)
    rt2 = find(y)
    if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1] def union(x,y):
    rt1 = find(x)
    rt2 = find(y)
    if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1] union def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x find ans = (N*(N-1))//2 (N*(N-1))//2 ans ans -= (z*(z-1))//2 (z*(z-1))//2 ans y = T[rt2][1] T[rt2][1] y
def find(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
def union(x,y):
    rt1 = find(x)
    rt2 = find(y)
    if T[rt1][1]>=T[rt2][1]:
        T[rt2][0] = rt1
        T[rt1][1] += T[rt2][1]
    else:
        T[rt1][0] = rt2
        T[rt2][1] += T[rt1][1]
N,M = map(int,input().split())
E = [list(map(int,input().split())) for _ in range(M)]
T = {i:[i,1] for i in range(1,N+1)}
RT = {i:1 for i in range(1,N+1)}
cnt = 0
ans = (N*(N-1))//2
A = []
A.append(ans)
for i in range(M-1,-1,-1):
    a,b = E[i]
    rt1 = find(a)
    rt2 = find(b)
    if rt1==rt2:
        A.append(ans)
    else:
        x = T[rt1][1]
        y = T[rt2][1]
        ans += (x*(x-1))//2+(y*(y-1))//2
        union(a,b)
        rt = find(a)
        z = T[rt][1]
        ans -= (z*(z-1))//2
        A.append(ans)
A = A[::-1]
for i in range(1,M+1):
    print(A[i])