#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

#https://note.nkmk.me/python-union-find/

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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=MI()
lis=[LI() for i in range(m)]
u=UnionFind(n)
def com(x):
    return (x*(x-1))//2
ans=[]
for i in range(m):
    j=m-i-1
    #print(u.group_count())
    x,y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)]
    u.union(lis[j][0]-1,lis[j][1]-1)
    z=-u.parents[u.find(lis[j][0]-1)]
    delta=com(z)-com(x)-com(y)
    #print(x,y,z)
    #print(max(delta,0))
    ans.append(max(delta,0))
#print(ans)
val=[com(n) for i in range(m)]
for i in range(m-1):
    val[i+1]=val[i]-ans[i]
#print(val)
for i in range(m):
    j=m-i-1
    print(val[j])
    
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def SI(): return input().rstrip() SI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) 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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

     members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if self.find(i) == root for i in range(self.n) if self.find(i) == root i range(self.n) range self.n self n self.find(i) == root self.find(i) self.find self find i root if self.find(i) == root i return [i for i in range(self.n) if self.find(i) == root] [i for i in range(self.n) if self.find(i) == root] self self x x def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

     roots i for i, x in enumerate(self.parents) if x < 0 for i, x in enumerate(self.parents) if x < 0 i x enumerate(self.parents) enumerate self.parents self parents x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.parents) if x < 0] [i for i, x in enumerate(self.parents) if x < 0] self self def group_count(self):
        return len(self.roots())

     group_count return len(self.roots()) len(self.roots()) len self.roots() self.roots self roots self self def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

     all_group_members r: self.members(r) for r in self.roots() for r in self.roots() r self.roots() self.roots self roots for r in self.roots() r self.members(r) self.members self members r return {r: self.members(r) for r in self.roots()} {r: self.members(r) for r in self.roots()} self self def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) __str__ return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) '\n'.join '\n' join '{}: {}'.format(r, self.members(r)) '{}: {}'.format '{}: {}' format r self.members(r) self.members self members r self self n,m=MI() n MI() MI m LI() for i in range(m) for i in range(m) i range(m) range m for i in range(m) LI() LI lis=[LI() for i in range(m)] lis [LI() for i in range(m)] u=UnionFind(n) u UnionFind(n) UnionFind n def com(x):
    return (x*(x-1))//2 com return (x*(x-1))//2 (x*(x-1))//2 x*(x-1) x x-1 x 1 2 x x ans=[] ans [] for i in range(m):
    j=m-i-1
    #print(u.group_count())
    x,y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)]
    u.union(lis[j][0]-1,lis[j][1]-1)
    z=-u.parents[u.find(lis[j][0]-1)]
    delta=com(z)-com(x)-com(y)
    #print(x,y,z)
    #print(max(delta,0))
    ans.append(max(delta,0))
#print(ans) i range(m) range m j=m-i-1 j m-i-1 m-i m i 1 x,y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)] x -u.parents[u.find(lis[j][0]-1)] u.parents[u.find(lis[j][0]-1)] u.parents u parents u.find(lis[j][0]-1) u.find u find lis[j][0]-1 lis[j][0] [j] lis j 0 1 y -u.parents[u.find(lis[j][1]-1)] u.parents[u.find(lis[j][1]-1)] u.parents u parents u.find(lis[j][1]-1) u.find u find lis[j][1]-1 lis[j][1] [j] lis j 1 1 u.union(lis[j][0]-1,lis[j][1]-1) u.union u union lis[j][0]-1 lis[j][0] [j] lis j 0 1 lis[j][1]-1 lis[j][1] [j] lis j 1 1 z=-u.parents[u.find(lis[j][0]-1)] z -u.parents[u.find(lis[j][0]-1)] u.parents[u.find(lis[j][0]-1)] u.parents u parents u.find(lis[j][0]-1) u.find u find lis[j][0]-1 lis[j][0] [j] lis j 0 1 delta=com(z)-com(x)-com(y) delta com(z)-com(x)-com(y) com(z)-com(x) com(z) com z com(x) com x com(y) com y ans.append(max(delta,0)) ans.append ans append max(delta,0) max delta 0 com(n) for i in range(m) for i in range(m) i range(m) range m for i in range(m) com(n) com n val=[com(n) for i in range(m)] val [com(n) for i in range(m)] for i in range(m-1):
    val[i+1]=val[i]-ans[i]
#print(val) i range(m-1) range m-1 m 1 val[i+1]=val[i]-ans[i] val[i+1] val i+1 i 1 val[i]-ans[i] val[i] val i ans[i] ans i for i in range(m):
    j=m-i-1
    print(val[j])
     i range(m) range m j=m-i-1 j m-i-1 m-i m i 1 print(val[j]) print val[j] val j input = sys.stdin.readline sys.stdin.readline input def I(): return int(input()) def I(): return int(input()) I mod = 10**9 + 7 10**9 + 7 mod y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)] -u.parents[u.find(lis[j][1]-1)] y def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI def SI(): return input().rstrip() def SI(): return input().rstrip() SI val=[com(n) for i in range(m)] [com(n) for i in range(m)] val inf = 10**17 10**17 inf delta=com(z)-com(x)-com(y) com(z)-com(x)-com(y) delta u=UnionFind(n) UnionFind(n) u def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI 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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) 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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) UnionFind m=MI() MI() m def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 z=-u.parents[u.find(lis[j][0]-1)] -u.parents[u.find(lis[j][0]-1)] z n,m=MI() MI() n ans=[] [] ans def com(x):
    return (x*(x-1))//2 def com(x):
    return (x*(x-1))//2 com lis=[LI() for i in range(m)] [LI() for i in range(m)] lis j=m-i-1 m-i-1 j j=m-i-1 m-i-1 j def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns x,y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)] -u.parents[u.find(lis[j][0]-1)] x def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

#https://note.nkmk.me/python-union-find/

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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=MI()
lis=[LI() for i in range(m)]
u=UnionFind(n)
def com(x):
    return (x*(x-1))//2
ans=[]
for i in range(m):
    j=m-i-1
    #print(u.group_count())
    x,y=-u.parents[u.find(lis[j][0]-1)],-u.parents[u.find(lis[j][1]-1)]
    u.union(lis[j][0]-1,lis[j][1]-1)
    z=-u.parents[u.find(lis[j][0]-1)]
    delta=com(z)-com(x)-com(y)
    #print(x,y,z)
    #print(max(delta,0))
    ans.append(max(delta,0))
#print(ans)
val=[com(n) for i in range(m)]
for i in range(m-1):
    val[i+1]=val[i]-ans[i]
#print(val)
for i in range(m):
    j=m-i-1
    print(val[j])
    

