# coding: utf-8
import sys
stdin = sys.stdin

sr = lambda: stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(M)]
V = [x for x in range(N+1)]
total = N * (N-1) // 2

def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root

def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root

def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret

conv = 0
answer = []
group = [1] * (N+1)
for a, b in AB[::-1]:
    answer.append(total - conv)
    conv += merge(V, a, b)

for x in answer[::-1]:
    print(x) import sys sys stdin = sys.stdin stdin sys.stdin sys stdin sr = lambda: stdin.readline().rstrip() sr lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, M = lr() N lr() lr M lr() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) lr() lr AB = [lr() for _ in range(M)] AB [lr() for _ in range(M)] x for x in range(N+1) for x in range(N+1) x range(N+1) range N+1 N 1 for x in range(N+1) x V = [x for x in range(N+1)] V [x for x in range(N+1)] total = N * (N-1) // 2 total N * (N-1) // 2 N * (N-1) N N-1 N 1 2 def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root find parent = A[x] parent A[x] A x if parent == x: return x
     parent == x parent x root = find(A, parent) root find(A, parent) find A parent A[x] = root A[x] A x root return root root A A x x def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root union root, second = find(A, x), find(A, y) root find(A, x) find A x second find(A, y) find A y if root > second:
        second, root = root, second
     root > second root second second, root = root, second second root root second A[second] = root A[second] A second root A A x x y y def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret merge root_A = find(A, a) root_A find(A, a) find A a root_B = find(A, b) root_B find(A, b) find A b if root_A == root_B:
        return 0
     root_A == root_B root_A root_B return 0 0 ret = group[root_A] * group[root_B] ret group[root_A] * group[root_B] group[root_A] group root_A group[root_B] group root_B new_group = group[root_A] + group[root_B] new_group group[root_A] + group[root_B] group[root_A] group root_A group[root_B] group root_B group[root_A] = group[root_B] = new_group group[root_A] group root_A new_group = group[root_B] = new_group group[root_B] group root_B new_group union(A, a, b) union A a b return ret ret A A x x y y conv = 0 conv 0 answer = [] answer [] group = [1] * (N+1) group [1] * (N+1) [1] 1 N+1 N 1 for a, b in AB[::-1]:
    answer.append(total - conv)
    conv += merge(V, a, b) a b AB[::-1] AB ::-1 -1 answer.append(total - conv) answer.append answer append total - conv total conv conv += merge(V, a, b) conv merge(V, a, b) merge V a b for x in answer[::-1]:
    print(x) x answer[::-1] answer ::-1 -1 print(x) print x ir = lambda: int(sr()) lambda: int(sr()) ir def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret merge answer = [] [] answer total = N * (N-1) // 2 N * (N-1) // 2 total stdin = sys.stdin sys.stdin stdin V = [x for x in range(N+1)] [x for x in range(N+1)] V M = lr() lr() M AB = [lr() for _ in range(M)] [lr() for _ in range(M)] AB def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root union def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root find conv = 0 0 conv group = [1] * (N+1) [1] * (N+1) group conv += merge(V, a, b) merge(V, a, b) conv sr = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() sr N, M = lr() lr() N lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr
# coding: utf-8
import sys
stdin = sys.stdin

sr = lambda: stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
AB = [lr() for _ in range(M)]
V = [x for x in range(N+1)]
total = N * (N-1) // 2

def find(A, x):
    parent = A[x]
    if parent == x: return x
    root = find(A, parent)
    A[x] = root
    return root

def union(A, x, y):
    root, second = find(A, x), find(A, y)
    if root > second:
        second, root = root, second
    A[second] = root

def merge(A, x, y):
    root_A = find(A, a); root_B = find(A, b)
    if root_A == root_B:
        return 0
    ret = group[root_A] * group[root_B]
    new_group = group[root_A] + group[root_B]
    group[root_A] = group[root_B] = new_group
    union(A, a, b)
    return ret

conv = 0
answer = []
group = [1] * (N+1)
for a, b in AB[::-1]:
    answer.append(total - conv)
    conv += merge(V, a, b)

for x in answer[::-1]:
    print(x)
