import sys
from itertools import combinations

# https://ikatakos.com/pot/programming_algorithm/data_structure/union_find_tree
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main() import sys sys from itertools import combinations class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1 UnionFind def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

     __init__ self.table = [-1] * n self.table self table [-1] * n [-1] -1 n self.n = n self.n self n n self.inconvenience = n * (n - 1) // 2 self.inconvenience self inconvenience n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 self self n n def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

     _root stack = [] stack [] tbl = self.table tbl self.table self table while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
         tbl[x] >= 0 tbl[x] tbl x 0 stack.append(x) stack.append stack append x x = tbl[x] x tbl[x] tbl x for y in stack:
            tbl[y] = x
         y stack tbl[y] = x tbl[y] tbl y x return x x self self x x def find(self, x, y):
        return self._root(x) == self._root(y)

     find return self._root(x) == self._root(y) self._root(x) == self._root(y) self._root(x) self._root self _root x self._root(y) self._root self _root y self self x x y y def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1 union r1 = self._root(x) r1 self._root(x) self._root self _root x r2 = self._root(y) r2 self._root(y) self._root self _root y if r1 == r2:
            return
         r1 == r2 r1 r2 return d1 = self.table[r1] d1 self.table[r1] self.table self table r1 d2 = self.table[r2] d2 self.table[r2] self.table self table r2 self.inconvenience -= d1 * d2 self.inconvenience self inconvenience d1 * d2 d1 d2 if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1 d1 <= d2 d1 d2 self.table[r2] = r1 self.table[r2] self.table self table r2 r1 self.table[r1] += d2 self.table[r1] self.table self table r1 d2 self.table[r1] = r2 self.table[r1] self.table self table r1 r2 self.table[r2] += d1 self.table[r2] self.table self table r2 d1 self self x x y y def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    print("\n".join(map(str, ans))) main input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 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 bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)] bridges [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)] ans = [0] * m ans [0] * m [0] 0 m ans[-1] = n * (n - 1) // 2 ans[-1] ans -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 - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
     i range(m - 2, -1, -1) range m - 2 m 2 -1 -1 uf.union(*bridges[i + 1]) uf.union uf union *bridges[i + 1] bridges[i + 1] bridges i + 1 i 1 ans[i] = uf.inconvenience ans[i] ans i uf.inconvenience uf inconvenience print("\n".join(map(str, ans))) print "\n".join(map(str, ans)) "\n".join "\n" join map(str, ans) map str ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1 class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1 UnionFind def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    print("\n".join(map(str, ans))) def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    print("\n".join(map(str, ans))) main
import sys
from itertools import combinations

# https://ikatakos.com/pot/programming_algorithm/data_structure/union_find_tree
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n
        self.n = n
        self.inconvenience = n * (n - 1) // 2

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        self.inconvenience -= d1 * d2
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    bridges = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
    ans = [0] * m
    ans[-1] = n * (n - 1) // 2
    uf = UnionFind(n)
    for i in range(m - 2, -1, -1):
        uf.union(*bridges[i + 1])
        ans[i] = uf.inconvenience
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()
