# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y)

from sys import stdin
input = stdin.buffer.readline

def main():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

    ans = [0] * m
    uf = UnionFind(n)
    cnt = n * (n-1) // 2
    for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

    for i in ans:
        print(i)

main() class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
     __init__ self.n = n self.n self n n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self self n n def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
     find history = [] history [] while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
         self.parents[x] >= 0 self.parents[x] self.parents self parents x 0 history.append(x) history.append history append x x = self.parents[x] x self.parents[x] self.parents self parents x for node in history:
            self.parents[node] = x
         node history self.parents[node] = x self.parents[node] self.parents self parents node x return x x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
     union 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.parents[x] > self.parents[y]:
            x, y = y, x
         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x, y = y, x x y y x self.parents[x] += self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x self self x x y y def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
     size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x 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 from sys import stdin input = stdin.buffer.readline input stdin.buffer.readline stdin.buffer stdin buffer readline def main():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

    ans = [0] * m
    uf = UnionFind(n)
    cnt = n * (n-1) // 2
    for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

    for i in ans:
        print(i) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = [0] * m a [0] * m [0] 0 m b = [0] * m b [0] * m [0] 0 m for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

     ind range(m) range m i, j = map(int, input().split()) i map(int, input().split()) map int input().split() ().split () input split j a[ind] = i - 1 a[ind] a ind i - 1 i 1 b[ind] = j - 1 b[ind] b ind j - 1 j 1 ans = [0] * m ans [0] * m [0] 0 m uf = UnionFind(n) uf UnionFind(n) UnionFind n cnt = n * (n-1) // 2 cnt n * (n-1) // 2 n * (n-1) n n-1 n 1 2 for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

     ind range(m-1, -1, -1) range m-1 m 1 -1 -1 ans[ind] = cnt ans[ind] ans ind cnt if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

     not uf.same(a[ind], b[ind]) uf.same(a[ind], b[ind]) uf.same uf same a[ind] a ind b[ind] b ind cnt -= uf.size(a[ind]) * uf.size(b[ind]) cnt uf.size(a[ind]) * uf.size(b[ind]) uf.size(a[ind]) uf.size uf size a[ind] a ind uf.size(b[ind]) uf.size uf size b[ind] b ind uf.union(a[ind], b[ind]) uf.union uf union a[ind] a ind b[ind] b ind for i in ans:
        print(i) i ans print(i) print i main() main def main():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

    ans = [0] * m
    uf = UnionFind(n)
    cnt = n * (n-1) // 2
    for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

    for i in ans:
        print(i) def main():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

    ans = [0] * m
    uf = UnionFind(n)
    cnt = n * (n-1) // 2
    for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

    for i in ans:
        print(i) main class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind input = stdin.buffer.readline stdin.buffer.readline input
# Reference: https://note.nkmk.me/python-union-find/
class UnionFind:
    # if x is root: self.parents[x] = -(the number of the group nodes)
    # else: self.parents[x] = the parent of x
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # return the parent of x
    def find(self, x):
        history = []
        while self.parents[x] >= 0:
            history.append(x)
            x = self.parents[x]
        for node in history:
            self.parents[node] = x
        return x

    # merge the group of x and the group of y
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # return the size of the group of x
    def size(self, x):
        return -self.parents[self.find(x)]

    # return whether x and y in a same group
    def same(self, x, y):
        return self.find(x) == self.find(y)

from sys import stdin
input = stdin.buffer.readline

def main():
    n, m = map(int, input().split())
    a = [0] * m
    b = [0] * m
    for ind in range(m):
        i, j = map(int, input().split())
        a[ind] = i - 1
        b[ind] = j - 1

    ans = [0] * m
    uf = UnionFind(n)
    cnt = n * (n-1) // 2
    for ind in range(m-1, -1, -1):
        ans[ind] = cnt
        if not uf.same(a[ind], b[ind]):
            cnt -= uf.size(a[ind]) * uf.size(b[ind])
            uf.union(a[ind], b[ind])

    for i in ans:
        print(i)

main()