# 20-08-12再トライ
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

    def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

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

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

N, M = [int(x) for x in input().split()]
E = [tuple(int(x) - 1 for x in input().split()) for _ in range(M)]
inconv = [0] * M
inconv[M - 1] = N * (N - 1) // 2
uf = UnionFind(N)

for i in range(M - 1, 0, -1):
    a = E[i][0]
    b = E[i][1]
    inconv[i - 1] = inconv[i]
    if uf.same(a, b):
        continue
    inconv[i - 1] -= uf.size(a) * uf.size(b)
    uf.union(a, b)

for i in range(M):
    print(inconv[i]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

    def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

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

    def size(self, x):
        return self._size[self.find(x)] UnionFind def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

     __init__ self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self.par = list(range(n)) self.par self par list(range(n)) list range(n) range n self._size = [1] * n self._size self _size [1] * n [1] 1 n self self n n def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

     find ch = [] ch [] while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
         self.par[x] != x self.par[x] self.par self par x x ch.append(x) ch.append ch append x x = self.par[x] x self.par[x] self.par self par x for c in ch:
            self.par[c] = x

         c ch self.par[c] = x self.par[c] self.par self par c x return x x self self x x def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

     union rx = self.find(x) rx self.find(x) self.find self find x ry = self.find(y) ry self.find(y) self.find self find y if rx == ry:
            return
         rx == ry rx ry return if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

     self.rank[rx] >= self.rank[ry] self.rank[rx] self.rank self rank rx self.rank[ry] self.rank self rank ry self.par[ry] = rx self.par[ry] self.par self par ry rx self._size[rx] += self._size[ry] self._size[rx] self._size self _size rx self._size[ry] self._size self _size ry if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
         self.rank[rx] == self.rank[ry] self.rank[rx] self.rank self rank rx self.rank[ry] self.rank self rank ry self.rank[rx] += 1 self.rank[rx] self.rank self rank rx 1 self.par[rx] = ry self.par[rx] self.par self par rx ry self._size[ry] += self._size[rx] self._size[ry] self._size self _size ry self._size[rx] self._size self _size rx 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._size[self.find(x)] size return self._size[self.find(x)] self._size[self.find(x)] self._size self _size self.find(x) self.find self find x self self x x int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N, M = [int(x) for x in input().split()] N [int(x) for x in input().split()] M tuple(int(x) - 1 for x in input().split()) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(int(x) - 1 for x in input().split()) tuple int(x) - 1 int(x) int x 1 E = [tuple(int(x) - 1 for x in input().split()) for _ in range(M)] E [tuple(int(x) - 1 for x in input().split()) for _ in range(M)] inconv = [0] * M inconv [0] * M [0] 0 M inconv[M - 1] = N * (N - 1) // 2 inconv[M - 1] inconv M - 1 M 1 N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 uf = UnionFind(N) uf UnionFind(N) UnionFind N for i in range(M - 1, 0, -1):
    a = E[i][0]
    b = E[i][1]
    inconv[i - 1] = inconv[i]
    if uf.same(a, b):
        continue
    inconv[i - 1] -= uf.size(a) * uf.size(b)
    uf.union(a, b) i range(M - 1, 0, -1) range M - 1 M 1 0 -1 a = E[i][0] a E[i][0] [i] E i 0 b = E[i][1] b E[i][1] [i] E i 1 inconv[i - 1] = inconv[i] inconv[i - 1] inconv i - 1 i 1 inconv[i] inconv i if uf.same(a, b):
        continue
     uf.same(a, b) uf.same uf same a b continue inconv[i - 1] -= uf.size(a) * uf.size(b) inconv[i - 1] inconv i - 1 i 1 uf.size(a) * uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b for i in range(M):
    print(inconv[i]) i range(M) range M print(inconv[i]) print inconv[i] inconv i M = [int(x) for x in input().split()] [int(x) for x in input().split()] M b = E[i][1] E[i][1] b input = sys.stdin.readline sys.stdin.readline input N, M = [int(x) for x in input().split()] [int(x) for x in input().split()] N a = E[i][0] E[i][0] a class UnionFind():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

    def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

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

    def size(self, x):
        return self._size[self.find(x)] class UnionFind():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

    def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

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

    def size(self, x):
        return self._size[self.find(x)] UnionFind inconv = [0] * M [0] * M inconv E = [tuple(int(x) - 1 for x in input().split()) for _ in range(M)] [tuple(int(x) - 1 for x in input().split()) for _ in range(M)] E uf = UnionFind(N) UnionFind(N) uf
# 20-08-12再トライ
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.rank = [0] * n
        self.par = list(range(n))
        self._size = [1] * n  # 木の根のみ有効、集合に属する要素数

    def find(self, x):
        ch = []
        while self.par[x] != x:
            ch.append(x)
            x = self.par[x]
        for c in ch:
            self.par[c] = x

        return x

    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
        if self.rank[rx] >= self.rank[ry]:
            self.par[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        else:
            self.par[rx] = ry
            self._size[ry] += self._size[rx]

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

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

N, M = [int(x) for x in input().split()]
E = [tuple(int(x) - 1 for x in input().split()) for _ in range(M)]
inconv = [0] * M
inconv[M - 1] = N * (N - 1) // 2
uf = UnionFind(N)

for i in range(M - 1, 0, -1):
    a = E[i][0]
    b = E[i][1]
    inconv[i - 1] = inconv[i]
    if uf.same(a, b):
        continue
    inconv[i - 1] -= uf.size(a) * uf.size(b)
    uf.union(a, b)

for i in range(M):
    print(inconv[i])