import sys

input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]        

def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
        
if __name__ == "__main__":
    main()
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]         UnionFind def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

     __init__ self.n = n self.n self n n self.par = [-1]*(n+1) self.par self par [-1]*(n+1) [-1] -1 n+1 n 1 self self n n def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

     find if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

     self.par[x] < 0 self.par[x] self.par self par x 0 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 union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[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.par[x] > self.par[y]:
            x, y = y, x
        
         self.par[x] > self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y x, y = y, x x y y x self.par[x] += self.par[y] self.par[x] self.par self par x self.par[y] self.par self par y self.par[y] = x self.par[y] self.par self par y x self self x x y y def same(self, x, y):
        return self.find(x) == self.find(y)#x,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 size(self, x):
        return -self.par[self.find(x)]
    
     size return -self.par[self.find(x)] -self.par[self.find(x)] self.par[self.find(x)] self.par self par self.find(x) self.find self find x self self x x def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]         members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if root == self.find(i) for i in range(self.n) if root == self.find(i) i range(self.n) range self.n self n root == self.find(i) root self.find(i) self.find self find i if root == self.find(i) i return [i for i in range(self.n) if root == self.find(i)] [i for i in range(self.n) if root == self.find(i)] self self x x def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
         main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m bridge = [None]*m bridge [None]*m [None] None m for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
     i range(m) range m int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x bridge[i] = [int(x) for x in input().split()] bridge[i] bridge i [int(x) for x in input().split()] union = UnionFind(n) union UnionFind(n) UnionFind n ans = [0]*m ans [0]*m [0] 0 m for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
     i range(m) range m a, b = bridge[m-1-i][0], bridge[m-1-i][1] a bridge[m-1-i][0] [m-1-i] bridge m-1-i m-1 m 1 i 0 b bridge[m-1-i][1] [m-1-i] bridge m-1-i m-1 m 1 i 1 if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
         union.same(a, b) == False union.same(a, b) union.same union same a b False ans[i] = union.size(a)*union.size(b) ans[i] ans i union.size(a)*union.size(b) union.size(a) union.size union size a union.size(b) union.size union size b if i != 0:
            ans[i] += ans[i-1]
         i != 0 i 0 ans[i] += ans[i-1] ans[i] ans i ans[i-1] ans i-1 i 1 union.union(a, b) union.union union union a b for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
     i range(1, m) range 1 m print(n*(n-1)//2-ans[m-1-i]) print n*(n-1)//2-ans[m-1-i] n*(n-1)//2 n*(n-1) n n-1 n 1 2 ans[m-1-i] ans m-1-i m-1 m 1 i print(n*(n-1)//2) print n*(n-1)//2 n*(n-1) n n-1 n 1 2 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]         class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]         UnionFind def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
         def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
         main
import sys

input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1]*(n+1)#それぞれの要素がどの要素の子であるか

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]#それぞれの要素の根を再帰的に求める

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        
        self.par[x] += self.par[y]
        self.par[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)#x,yが同じ集合に属するかどうか
    
    def size(self, x):
        return -self.par[self.find(x)]
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if root == self.find(i)]        

def main():
    n, m = map(int, input().split())
    bridge = [None]*m
    for i in range(m):
        bridge[i] = [int(x) for x in input().split()]
    
    union = UnionFind(n)
    
    ans = [0]*m
    for i in range(m):
        a, b = bridge[m-1-i][0], bridge[m-1-i][1]
        if union.same(a, b) == False:
        	ans[i] = union.size(a)*union.size(b)
        if i != 0:
            ans[i] += ans[i-1]
        union.union(a, b)
    
    for i in range(1, m):
        print(n*(n-1)//2-ans[m-1-i])
    print(n*(n-1)//2)
        
if __name__ == "__main__":
    main()

