import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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

    def size(self, x):
        return -self.p[self.find(x)]


n, m = map(int, input().split())
uf = UnionFind(n)
edges = [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)]


ans_inv = [n*(n-1)//2]
for a, b in reversed(edges):
    if uf.same(a, b):
        ans = ans_inv[-1]
    else:
        x = uf.size(a)
        y = uf.size(b)
        ans = ans_inv[-1]-x*y
    ans_inv.append(ans)
    uf.union(a, b)

print(*reversed(ans_inv[:-1]), sep='\n') import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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

    def size(self, x):
        return -self.p[self.find(x)] UnionFind def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

     __init__ self.p = [-1]*n self.p self p [-1]*n [-1] -1 n self.r = [1]*n self.r self r [1]*n [1] 1 n self self n n def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

     find if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

     self.p[x] < 0 self.p[x] self.p self p x 0 return x x self.p[x] = self.find(self.p[x]) self.p[x] self.p self p x self.find(self.p[x]) self.find self find self.p[x] self.p self p x return self.p[x] self.p[x] self.p self p x self self x x def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

     union rx, ry = self.find(x), self.find(y) rx self.find(x) self.find self find x ry self.find(y) self.find self find y if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

     rx != ry rx ry if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
             self.r[rx] > self.r[ry] self.r[rx] self.r self r rx self.r[ry] self.r self r ry rx, ry = ry, rx rx ry ry rx if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
             self.r[rx] == self.r[ry] self.r[rx] self.r self r rx self.r[ry] self.r self r ry self.r[ry] += 1 self.r[ry] self.r self r ry 1 self.p[ry] += self.p[rx] self.p[ry] self.p self p ry self.p[rx] self.p self p rx self.p[rx] = ry self.p[rx] self.p self p rx ry self self x x y y def same(self, x, y):
        return self.find(x) == self.find(y)

     same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def size(self, x):
        return -self.p[self.find(x)] size return -self.p[self.find(x)] -self.p[self.find(x)] self.p[self.find(x)] self.p self p self.find(x) self.find self find x self self x x n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m uf = UnionFind(n) uf UnionFind(n) UnionFind n tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m) for _ in range(m) _ range(m) range m for _ 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 edges = [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)] edges [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)] ans_inv = [n*(n-1)//2] ans_inv [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 for a, b in reversed(edges):
    if uf.same(a, b):
        ans = ans_inv[-1]
    else:
        x = uf.size(a)
        y = uf.size(b)
        ans = ans_inv[-1]-x*y
    ans_inv.append(ans)
    uf.union(a, b) a b reversed(edges) reversed edges if uf.same(a, b):
        ans = ans_inv[-1]
    else:
        x = uf.size(a)
        y = uf.size(b)
        ans = ans_inv[-1]-x*y
     uf.same(a, b) uf.same uf same a b ans = ans_inv[-1] ans ans_inv[-1] ans_inv -1 x = uf.size(a) x uf.size(a) uf.size uf size a y = uf.size(b) y uf.size(b) uf.size uf size b ans = ans_inv[-1]-x*y ans ans_inv[-1]-x*y ans_inv[-1] ans_inv -1 x*y x y ans_inv.append(ans) ans_inv.append ans_inv append ans uf.union(a, b) uf.union uf union a b print(*reversed(ans_inv[:-1]), sep='\n') print *reversed(ans_inv[:-1]) reversed(ans_inv[:-1]) reversed ans_inv[:-1] ans_inv :-1 -1 sep='\n' sep '\n' uf = UnionFind(n) UnionFind(n) uf ans = ans_inv[-1]-x*y ans_inv[-1]-x*y ans class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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

    def size(self, x):
        return -self.p[self.find(x)] class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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

    def size(self, x):
        return -self.p[self.find(x)] UnionFind m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n ans_inv = [n*(n-1)//2] [n*(n-1)//2] ans_inv ans = ans_inv[-1] ans_inv[-1] ans x = uf.size(a) uf.size(a) x y = uf.size(b) uf.size(b) y input = sys.stdin.readline sys.stdin.readline input edges = [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)] [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)] edges
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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

    def size(self, x):
        return -self.p[self.find(x)]


n, m = map(int, input().split())
uf = UnionFind(n)
edges = [tuple(map(lambda x: int(x)-1, input().split()))for _ in range(m)]


ans_inv = [n*(n-1)//2]
for a, b in reversed(edges):
    if uf.same(a, b):
        ans = ans_inv[-1]
    else:
        x = uf.size(a)
        y = uf.size(b)
        ans = ans_inv[-1]-x*y
    ans_inv.append(ans)
    uf.union(a, b)

print(*reversed(ans_inv[:-1]), sep='\n')