import sys
import collections

readline = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

def main():
    N, M = map(int, readline().split())
    nodelist = []
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.append((A, B))
    
    uf = UnionFind(N)
    anstmp = (N*(N-1))//2
    anslist = [anstmp]
    for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
    anslist = anslist[:-1]
    for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans)

if __name__ == "__main__":
    main() import sys sys import collections collections readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def msize(self, x):
        return -self.size[self.find(x)] UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank = [0]*n self.rank self rank [0]*n [0] 0 n self.size = [1]*n self.size self size [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

     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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[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.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x self.parents[x] = y self.parents[x] self.parents self parents x y self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y self.parents[y] = x self.parents[y] self.parents self parents 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 self x x y y def msize(self, x):
        return -self.size[self.find(x)] msize return -self.size[self.find(x)] -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 def main():
    N, M = map(int, readline().split())
    nodelist = []
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.append((A, B))
    
    uf = UnionFind(N)
    anstmp = (N*(N-1))//2
    anslist = [anstmp]
    for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
    anslist = anslist[:-1]
    for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans) main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M nodelist = [] nodelist [] for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.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 A -= 1 A 1 B -= 1 B 1 nodelist.append((A, B)) nodelist.append nodelist append (A, B) A B uf = UnionFind(N) uf UnionFind(N) UnionFind N anstmp = (N*(N-1))//2 anstmp (N*(N-1))//2 N*(N-1) N N-1 N 1 2 anslist = [anstmp] anslist [anstmp] anstmp for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
     _ range(M) range M node = nodelist.pop() node nodelist.pop() nodelist.pop nodelist pop n0 = uf.find(node[0]) n0 uf.find(node[0]) uf.find uf find node[0] node 0 n1 = uf.find(node[1]) n1 uf.find(node[1]) uf.find uf find node[1] node 1 if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
         n0 != n1 n0 n1 n0size = uf.size[n0] n0size uf.size[n0] uf.size uf size n0 n1size = uf.size[n1] n1size uf.size[n1] uf.size uf size n1 n0size = 0 n0size 0 n1size = 0 n1size 0 uf.union(node[0], node[1]) uf.union uf union node[0] node 0 node[1] node 1 anstmp = anslist[-1] anstmp anslist[-1] anslist -1 ans = anstmp - n0size*n1size ans anstmp - n0size*n1size anstmp n0size*n1size n0size n1size anslist.append(ans) anslist.append anslist append ans anslist = anslist[:-1] anslist anslist[:-1] anslist :-1 -1 for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans) _ range(len(anslist)) range len(anslist) len anslist ans = anslist.pop() ans anslist.pop() anslist.pop anslist pop print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def msize(self, x):
        return -self.size[self.find(x)] class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def msize(self, x):
        return -self.size[self.find(x)] UnionFind def main():
    N, M = map(int, readline().split())
    nodelist = []
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.append((A, B))
    
    uf = UnionFind(N)
    anstmp = (N*(N-1))//2
    anslist = [anstmp]
    for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
    anslist = anslist[:-1]
    for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans) def main():
    N, M = map(int, readline().split())
    nodelist = []
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.append((A, B))
    
    uf = UnionFind(N)
    anstmp = (N*(N-1))//2
    anslist = [anstmp]
    for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
    anslist = anslist[:-1]
    for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans) main readline = sys.stdin.readline sys.stdin.readline readline
import sys
import collections

readline = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [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.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

def main():
    N, M = map(int, readline().split())
    nodelist = []
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        nodelist.append((A, B))
    
    uf = UnionFind(N)
    anstmp = (N*(N-1))//2
    anslist = [anstmp]
    for _ in range(M):
        node = nodelist.pop()
        n0 = uf.find(node[0])
        n1 = uf.find(node[1])
        if n0 != n1:
            n0size = uf.size[n0]
            n1size = uf.size[n1]
        else:
            n0size = 0; n1size = 0
        uf.union(node[0], node[1])
        anstmp = anslist[-1]
        ans = anstmp - n0size*n1size
        anslist.append(ans)
    anslist = anslist[:-1]
    for _ in range(len(anslist)):
        ans = anslist.pop()
        print(ans)

if __name__ == "__main__":
    main()
