import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

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

    def trees(self):
        return self.n - self._edges

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

n, m = na()
ab = nan(m)
ab.reverse()

uf = UnionFind(n)
cur = n * (n - 1) // 2
ans = [cur]
for i in range(m - 1):
    a, b = ab[i]
    a -= 1
    b -= 1
    p = uf.size(a)
    q = uf.size(b)
    if uf.same(a, b):
        p = 0
    uf.unite(a, b)
    cur -= p * q
    ans.append(cur)

ans.reverse()
print(*ans, sep="\n") import sys sys stdin = sys.stdin stdin sys.stdin sys stdin inf = 1 << 60 inf 1 << 60 1 60 mod = 1000000007 mod 1000000007 sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 ni = lambda: int(ns()) ni lambda: int(ns()) int(ns()) int ns() ns ni() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) ni() ni nin = lambda y: [ni() for _ in range(y)] nin lambda y: [ni() for _ in range(y)] [ni() for _ in range(y)] y na = lambda: list(map(int, stdin.readline().split())) na lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split na() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) na() na nan = lambda y: [na() for _ in range(y)] nan lambda y: [na() for _ in range(y)] [na() for _ in range(y)] y nf = lambda: float(ns()) nf lambda: float(ns()) float(ns()) float ns() ns nf() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) nf() nf nfn = lambda y: [nf() for _ in range(y)] nfn lambda y: [nf() for _ in range(y)] [nf() for _ in range(y)] y nfa = lambda: list(map(float, stdin.readline().split())) nfa lambda: list(map(float, stdin.readline().split())) list(map(float, stdin.readline().split())) list map(float, stdin.readline().split()) map float stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split nfa() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) nfa() nfa nfan = lambda y: [nfa() for _ in range(y)] nfan lambda y: [nfa() for _ in range(y)] [nfa() for _ in range(y)] y ns = lambda: stdin.readline().rstrip() ns lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip ns() for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) ns() ns nsn = lambda y: [ns() for _ in range(y)] nsn lambda y: [ns() for _ in range(y)] [ns() for _ in range(y)] y list(ns()) for _ in range(y) for _ in range(y) _ range(y) range y for _ in range(y) list(ns()) list ns() ns ncl = lambda y: [list(ns()) for _ in range(y)] ncl lambda y: [list(ns()) for _ in range(y)] [list(ns()) for _ in range(y)] y nas = lambda: stdin.readline().split() nas lambda: stdin.readline().split() stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

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

    def trees(self):
        return self.n - self._edges

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

     __init__ self.n = n self.n self n n i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.par = [i for i in range(n)] self.par self par [i for i in range(n)] 0 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 0 self.rank = [0 for _ in range(n)] self.rank self rank [0 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 self._size = [1 for _ in range(n)] self._size self _size [1 for _ in range(n)] self._edges = 0 self._edges self _edges 0 self self n n def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     find if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

     self.par[x] == x self.par[x] self.par self par x x return x x self.par[x] = self.find(self.par[x]) self.par[x] self.par self par x self.find(self.par[x]) self.find self find self.par[x] self.par self par x return self.par[x] self.par[x] self.par self par x self self x x def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

     unite x = self.find(x) x self.find(x) self.find self find x y = self.find(y) y self.find(y) self.find self find y if x == y:
            return
         x == y x y return if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

     self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.par[x] = y self.par[x] self.par self par x y self._size[y] += self._size[x] self._size[y] self._size self _size y self._size[x] self._size self _size x self._edges += 1 self._edges self _edges 1 self.par[y] = x self.par[y] self.par self par y x if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
             self.rank[x] == self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x] += 1 self.rank[x] self.rank self rank x 1 self._size[x] += self._size[y] self._size[x] self._size self _size x self._size[y] self._size self _size y self._edges += 1 self._edges self _edges 1 self self x x y y def size(self, x):
        x = self.find(x)
        return self._size[x]

     size x = self.find(x) x self.find(x) self.find self find x return self._size[x] self._size[x] self._size self _size x self self x x def trees(self):
        return self.n - self._edges

     trees return self.n - self._edges self.n - self._edges self.n self n self._edges self _edges self self 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 n, m = na() n na() na m ab = nan(m) ab nan(m) nan m ab.reverse() ab.reverse ab reverse uf = UnionFind(n) uf UnionFind(n) UnionFind n cur = n * (n - 1) // 2 cur n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 ans = [cur] ans [cur] cur for i in range(m - 1):
    a, b = ab[i]
    a -= 1
    b -= 1
    p = uf.size(a)
    q = uf.size(b)
    if uf.same(a, b):
        p = 0
    uf.unite(a, b)
    cur -= p * q
    ans.append(cur) i range(m - 1) range m - 1 m 1 a, b = ab[i] a ab[i] ab i b a -= 1 a 1 b -= 1 b 1 p = uf.size(a) p uf.size(a) uf.size uf size a q = uf.size(b) q uf.size(b) uf.size uf size b if uf.same(a, b):
        p = 0
     uf.same(a, b) uf.same uf same a b p = 0 p 0 uf.unite(a, b) uf.unite uf unite a b cur -= p * q cur p * q p q ans.append(cur) ans.append ans append cur ans.reverse() ans.reverse ans reverse print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" uf = UnionFind(n) UnionFind(n) uf nf = lambda: float(ns()) lambda: float(ns()) nf p = 0 0 p nfan = lambda y: [nfa() for _ in range(y)] lambda y: [nfa() for _ in range(y)] nfan a, b = ab[i] ab[i] a na = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) na p = uf.size(a) uf.size(a) p ni = lambda: int(ns()) lambda: int(ns()) ni q = uf.size(b) uf.size(b) q b -= 1 1 b inf = 1 << 60 1 << 60 inf nan = lambda y: [na() for _ in range(y)] lambda y: [na() for _ in range(y)] nan a -= 1 1 a ncl = lambda y: [list(ns()) for _ in range(y)] lambda y: [list(ns()) for _ in range(y)] ncl nas = lambda: stdin.readline().split() lambda: stdin.readline().split() nas nfn = lambda y: [nf() for _ in range(y)] lambda y: [nf() for _ in range(y)] nfn nsn = lambda y: [ns() for _ in range(y)] lambda y: [ns() for _ in range(y)] nsn ab = nan(m) nan(m) ab n, m = na() na() n ans = [cur] [cur] ans b = ab[i] ab[i] b ns = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() ns cur = n * (n - 1) // 2 n * (n - 1) // 2 cur nin = lambda y: [ni() for _ in range(y)] lambda y: [ni() for _ in range(y)] nin mod = 1000000007 1000000007 mod nfa = lambda: list(map(float, stdin.readline().split())) lambda: list(map(float, stdin.readline().split())) nfa stdin = sys.stdin sys.stdin stdin class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

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

    def trees(self):
        return self.n - self._edges

    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

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

    def trees(self):
        return self.n - self._edges

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind cur -= p * q p * q cur m = na() na() m
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]
        self._edges = 0

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
            self._edges += 1
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
            self._edges += 1

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

    def trees(self):
        return self.n - self._edges

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

n, m = na()
ab = nan(m)
ab.reverse()

uf = UnionFind(n)
cur = n * (n - 1) // 2
ans = [cur]
for i in range(m - 1):
    a, b = ab[i]
    a -= 1
    b -= 1
    p = uf.size(a)
    q = uf.size(b)
    if uf.same(a, b):
        p = 0
    uf.unite(a, b)
    cur -= p * q
    ans.append(cur)

ans.reverse()
print(*ans, sep="\n")