import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)]

N, M = mi()
A = li2(M)
islands = UnionFind(N)

ans = [N*(N-1)//2] * (M+1)
for i in reversed(range(M)):
    s, t = A[i][0]-1, A[i][1]-1
    if islands.same(s, t):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - islands.size(s) * islands.size(t)
    islands.unite(s, t)

for num in ans[1:]:
    print(num) import sys sys sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 def ii(): return int(sys.stdin.readline()) ii def mi(): return map(int, sys.stdin.readline().split()) mi def li(): return list(map(int, sys.stdin.readline().split())) li list(map(int, sys.stdin.readline().split())) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2 N N [ini]*i for _ in range(j) for _ in range(j) _ range(j) range j for _ in range(j) [ini]*i [ini] ini i def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A)) dp2 ini ini i i j j class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)] UnionFind def __init__(self, n):
        self.d = [-1]*n
    
     __init__ self.d = [-1]*n self.d self d [-1]*n [-1] -1 n self self n n def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
     find if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
     self.d[x] < 0 self.d[x] self.d self d x 0 return x x self.d[x] = self.find(self.d[x]) self.d[x] self.d self d x self.find(self.d[x]) self.find self find self.d[x] self.d self d x return self.find(self.d[x]) self.find(self.d[x]) self.find self find self.d[x] self.d self d x self self x x def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
     unite 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 False
         x==y x y return False False if self.d[x] > self.d[y]:
            x, y = y, x
         self.d[x] > self.d[y] self.d[x] self.d self d x self.d[y] self.d self d y x, y = y, x x y y x self.d[x] += self.d[y] self.d[x] self.d self d x self.d[y] self.d self d y self.d[y] = x self.d[y] self.d self d y x return True True self self x x y y def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
     same if self.find(x)==self.find(y):
            return True
         self.find(x)==self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y return True True return False False self self x x y y def size(self, x):
        return (-1) * self.d[self.find(x)] size return (-1) * self.d[self.find(x)] (-1) * self.d[self.find(x)] -1 self.d[self.find(x)] self.d self d self.find(x) self.find self find x self self x x N, M = mi() N mi() mi M A = li2(M) A li2(M) li2 M islands = UnionFind(N) islands UnionFind(N) UnionFind N ans = [N*(N-1)//2] * (M+1) ans [N*(N-1)//2] * (M+1) [N*(N-1)//2] N*(N-1)//2 N*(N-1) N N-1 N 1 2 M+1 M 1 for i in reversed(range(M)):
    s, t = A[i][0]-1, A[i][1]-1
    if islands.same(s, t):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - islands.size(s) * islands.size(t)
    islands.unite(s, t) i reversed(range(M)) reversed range(M) range M s, t = A[i][0]-1, A[i][1]-1 s A[i][0]-1 A[i][0] [i] A i 0 1 t A[i][1]-1 A[i][1] [i] A i 1 1 if islands.same(s, t):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - islands.size(s) * islands.size(t)
     islands.same(s, t) islands.same islands same s t ans[i] = ans[i+1] ans[i] ans i ans[i+1] ans i+1 i 1 ans[i] = ans[i+1] - islands.size(s) * islands.size(t) ans[i] ans i ans[i+1] - islands.size(s) * islands.size(t) ans[i+1] ans i+1 i 1 islands.size(s) * islands.size(t) islands.size(s) islands.size islands size s islands.size(t) islands.size islands size t islands.unite(s, t) islands.unite islands unite s t for num in ans[1:]:
    print(num) num ans[1:] ans 1: 1 print(num) print num def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A)) def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A)) dp2 islands = UnionFind(N) UnionFind(N) islands N, M = mi() mi() N t = A[i][0]-1, A[i][1]-1 A[i][1]-1 t def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] li2 s, t = A[i][0]-1, A[i][1]-1 A[i][0]-1 s A = li2(M) li2(M) A ans = [N*(N-1)//2] * (M+1) [N*(N-1)//2] * (M+1) ans class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)] class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)] UnionFind M = mi() mi() M def ii(): return int(sys.stdin.readline()) def ii(): return int(sys.stdin.readline()) ii def mi(): return map(int, sys.stdin.readline().split()) def mi(): return map(int, sys.stdin.readline().split()) mi def li(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) li
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

class UnionFind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)]

N, M = mi()
A = li2(M)
islands = UnionFind(N)

ans = [N*(N-1)//2] * (M+1)
for i in reversed(range(M)):
    s, t = A[i][0]-1, A[i][1]-1
    if islands.same(s, t):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - islands.size(s) * islands.size(t)
    islands.unite(s, t)

for num in ans[1:]:
    print(num)