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,input().split())
    ab = [tuple(map(int,input().split())) for _ in range(m)]

    uf = UnionFind(n)

    ans = [n*(n-1)//2]

    for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
    print(*ans[::-1][1:], sep="\n")

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) 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,input().split())
    ab = [tuple(map(int,input().split())) for _ in range(m)]

    uf = UnionFind(n)

    ans = [n*(n-1)//2]

    for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
    print(*ans[::-1][1:], sep="\n") main n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m tuple(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split ab = [tuple(map(int,input().split())) for _ in range(m)] ab [tuple(map(int,input().split())) for _ in range(m)] uf = UnionFind(n) uf UnionFind(n) UnionFind n ans = [n*(n-1)//2] ans [n*(n-1)//2] n*(n-1)//2 n*(n-1) n n-1 n 1 2 for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
     a b ab[::-1] ab ::-1 -1 sa,sb=uf.size(a-1),uf.size(b-1) sa uf.size(a-1) uf.size uf size a-1 a 1 sb uf.size(b-1) uf.size uf size b-1 b 1 if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
         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 ans.append(ans[-1]-sa*sb) ans.append ans append ans[-1]-sa*sb ans[-1] ans -1 sa*sb sa sb uf.union(a-1,b-1) uf.union uf union a-1 a 1 b-1 b 1 print(*ans[::-1][1:], sep="\n") print *ans[::-1][1:] ans[::-1][1:] [::-1] ans ::-1 -1 1: 1 sep="\n" sep "\n" main() 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 def main():
    n, m = map(int,input().split())
    ab = [tuple(map(int,input().split())) for _ in range(m)]

    uf = UnionFind(n)

    ans = [n*(n-1)//2]

    for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
    print(*ans[::-1][1:], sep="\n") def main():
    n, m = map(int,input().split())
    ab = [tuple(map(int,input().split())) for _ in range(m)]

    uf = UnionFind(n)

    ans = [n*(n-1)//2]

    for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
    print(*ans[::-1][1:], sep="\n") 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)

def main():
    n, m = map(int,input().split())
    ab = [tuple(map(int,input().split())) for _ in range(m)]

    uf = UnionFind(n)

    ans = [n*(n-1)//2]

    for a,b in ab[::-1]:
        sa,sb=uf.size(a-1),uf.size(b-1)
        if uf.same(a-1,b-1):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1]-sa*sb)
        uf.union(a-1,b-1)
        
    print(*ans[::-1][1:], sep="\n")

main()