import sys
sys.setrecursionlimit(1000000)

def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

def get_size(s):
    return size[get_root(s)]

def update_size(x, y, s):
    size[get_root(s)] = x + y

n, m = map(int, input().split())
c = (n * (n - 1)) // 2
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
ans = [c]
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c)
for i in range(m - 1, -1, -1):
    print(ans[i]) import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s get_root if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
     s != root[s] s root[s] root s root[s] = get_root(root[s]) root[s] root s get_root(root[s]) get_root root[s] root s return root[s] root[s] root s return s s s s def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t unite root_s = get_root(s) root_s get_root(s) get_root s root_t = get_root(t) root_t get_root(t) get_root t if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t not root_s == root_t root_s == root_t root_s root_t if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t rank[s] == rank[t] rank[s] rank s rank[t] rank t root[root_t] = root_s root[root_t] root root_t root_s rank[root_s] += 1 rank[root_s] rank root_s 1 elif rank[s] > rank[t]:
            root[root_t] = root_s
         rank[s] > rank[t] rank[s] rank s rank[t] rank t root[root_t] = root_s root[root_t] root root_t root_s root[root_s] = root_t root[root_s] root root_s root_t s s t t def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False same if get_root(s) == get_root(t):
        return True
    else:
        return False get_root(s) == get_root(t) get_root(s) get_root s get_root(t) get_root t return True True return False False s s t t def get_size(s):
    return size[get_root(s)] get_size return size[get_root(s)] size[get_root(s)] size get_root(s) get_root s s s def update_size(x, y, s):
    size[get_root(s)] = x + y update_size size[get_root(s)] = x + y size[get_root(s)] size get_root(s) get_root s x + y x y x x y y s s n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c = (n * (n - 1)) // 2 c (n * (n - 1)) // 2 n * (n - 1) n n - 1 n 1 2 i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i root = [i for i in range(n)] root [i for i in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 rank = [1 for _ in range(n)] rank [1 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 size = [1 for _ in range(n)] size [1 for _ in range(n)] ans = [c] ans [c] c 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 v = [list(map(int, input().split())) for _ in range(m)] v [list(map(int, input().split())) for _ in range(m)] for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c) i range(m - 1, -1, -1) range m - 1 m 1 -1 -1 u = v[i] u v[i] v i u[0] -= 1 u[0] u 0 1 u[1] -= 1 u[1] u 1 1 if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
     not same(u[0], u[1]) same(u[0], u[1]) same u[0] u 0 u[1] u 1 x = get_size(u[0]) x get_size(u[0]) get_size u[0] u 0 y = get_size(u[1]) y get_size(u[1]) get_size u[1] u 1 unite(u[0], u[1]) unite u[0] u 0 u[1] u 1 update_size(x, y, u[0]) update_size x y u[0] u 0 c -= x * y c x * y x y ans.append(c) ans.append ans append c for i in range(m - 1, -1, -1):
    print(ans[i]) i range(m - 1, -1, -1) range m - 1 m 1 -1 -1 print(ans[i]) print ans[i] ans i n, m = map(int, input().split()) map(int, input().split()) n size = [1 for _ in range(n)] [1 for _ in range(n)] size c = (n * (n - 1)) // 2 (n * (n - 1)) // 2 c v = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] v x = get_size(u[0]) get_size(u[0]) x def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t unite def get_size(s):
    return size[get_root(s)] def get_size(s):
    return size[get_root(s)] get_size root = [i for i in range(n)] [i for i in range(n)] root def update_size(x, y, s):
    size[get_root(s)] = x + y def update_size(x, y, s):
    size[get_root(s)] = x + y update_size def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s get_root ans = [c] [c] ans u = v[i] v[i] u y = get_size(u[1]) get_size(u[1]) y c -= x * y x * y c m = map(int, input().split()) map(int, input().split()) m def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False same rank = [1 for _ in range(n)] [1 for _ in range(n)] rank
import sys
sys.setrecursionlimit(1000000)

def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

def get_size(s):
    return size[get_root(s)]

def update_size(x, y, s):
    size[get_root(s)] = x + y

n, m = map(int, input().split())
c = (n * (n - 1)) // 2
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
size = [1 for _ in range(n)]
ans = [c]
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    u = v[i]
    u[0] -= 1
    u[1] -= 1
    if not same(u[0], u[1]):
        x = get_size(u[0])
        y = get_size(u[1])
        unite(u[0], u[1])
        update_size(x, y, u[0])
        c -= x * y
    ans.append(c)
for i in range(m - 1, -1, -1):
    print(ans[i])