import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
def main():
    N, M = map(int, readline().split())
    uf = UnionFind(N)
    AB = []
    for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
    ans = [N*(N-1)//2]
    for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
    for i in range(M-1,-1,-1):
        print(ans[i])
if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
     __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):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
     find if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents 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
     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)]
     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 def main():
    N, M = map(int, readline().split())
    uf = UnionFind(N)
    AB = []
    for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
    ans = [N*(N-1)//2]
    for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
    for i in range(M-1,-1,-1):
        print(ans[i]) main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M uf = UnionFind(N) uf UnionFind(N) UnionFind N AB = [] AB [] for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
     _ range(M) range M a, b = map(int, readline().split()) a map(int, readline().split()) map int readline().split() ().split () readline split b AB.append((a,b)) AB.append AB append (a,b) a b ans = [N*(N-1)//2] ans [N*(N-1)//2] N*(N-1)//2 N*(N-1) N N-1 N 1 2 for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
     i range(M-1,-1,-1) range M-1 M 1 -1 -1 a,b = AB[i][0], AB[i][1] a AB[i][0] [i] AB i 0 b AB[i][1] [i] AB i 1 if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
     uf.same(a-1,b-1) uf.same uf same a-1 a 1 b-1 b 1 ans.append(ans[-1]) ans.append ans append ans[-1] ans -1 tmp = ans[-1] - uf.size(a-1)*uf.size(b-1) tmp ans[-1] - uf.size(a-1)*uf.size(b-1) ans[-1] ans -1 uf.size(a-1)*uf.size(b-1) uf.size(a-1) uf.size uf size a-1 a 1 uf.size(b-1) uf.size uf size b-1 b 1 ans.append(tmp) ans.append ans append tmp uf.union(a-1,b-1) uf.union uf union a-1 a 1 b-1 b 1 for i in range(M-1,-1,-1):
        print(ans[i]) i range(M-1,-1,-1) range M-1 M 1 -1 -1 print(ans[i]) print ans[i] ans i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def main():
    N, M = map(int, readline().split())
    uf = UnionFind(N)
    AB = []
    for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
    ans = [N*(N-1)//2]
    for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
    for i in range(M-1,-1,-1):
        print(ans[i]) def main():
    N, M = map(int, readline().split())
    uf = UnionFind(N)
    AB = []
    for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
    ans = [N*(N-1)//2]
    for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
    for i in range(M-1,-1,-1):
        print(ans[i]) main class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[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
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
def main():
    N, M = map(int, readline().split())
    uf = UnionFind(N)
    AB = []
    for _ in range(M):
        a, b = map(int, readline().split())
        AB.append((a,b))
    ans = [N*(N-1)//2]
    for i in range(M-1,-1,-1):
        a,b = AB[i][0], AB[i][1]
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            tmp = ans[-1] - uf.size(a-1)*uf.size(b-1)
            ans.append(tmp)
            uf.union(a-1,b-1)
    for i in range(M-1,-1,-1):
        print(ans[i])
if __name__ == '__main__':
    main()