import sys
def input():
    return sys.stdin.readline()[:-1]
n,m = map(int,input().split())
ab = []
for i in range(m):
     ab.append(list(map(int,input().split())))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
land = UnionFind(n)
all = int(n*(n-1)/2)
lis = [all]
for i in range(m-1):
    [a,b] = ab[-1-i]
    if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
    land.Unite(a,b)
    lis.append(all)
#print(lis)
for i in range(m):
    print(lis[-1-i]) import sys sys def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ab = [] ab [] for i in range(m):
     ab.append(list(map(int,input().split()))) i range(m) range m ab.append(list(map(int,input().split()))) ab.append ab append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] UnionFind def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
     __init__ self.n = n self.n self n n self.root = [-1]*(n+1) self.root self root [-1]*(n+1) [-1] -1 n+1 n 1 self.rnk = [0]*(n+1) self.rnk self rnk [0]*(n+1) [0] 0 n+1 n 1 self self n n def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
     Find_Root if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
     self.root[x]<0 self.root[x] self.root self root x 0 self.root[x] = self.Find_Root(self.root[x]) self.root[x] self.root self root x self.Find_Root(self.root[x]) self.Find_Root self Find_Root self.root[x] self.root self root x return self.root[x] self.root[x] self.root self root x self self x x def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
     Unite x = self.Find_Root(x) x self.Find_Root(x) self.Find_Root self Find_Root x y = self.Find_Root(y) y self.Find_Root(y) self.Find_Root self Find_Root y if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
     x == y x y return elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
         self.rnk[x] > self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.root[x] += self.root[y] self.root[x] self.root self root x self.root[y] self.root self root y self.root[y] = x self.root[y] self.root self root y x self.root[y] += self.root[x] self.root[y] self.root self root y self.root[x] self.root self root x self.root[x] = y self.root[x] self.root self root x y if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
     self.rnk[x] == self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.rnk[y] += 1 self.rnk[y] self.rnk self rnk y 1 self self x x y y def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
     isSameGroup return self.Find_Root(x) == self.Find_Root(y) self.Find_Root(x) == self.Find_Root(y) self.Find_Root(x) self.Find_Root self Find_Root x self.Find_Root(y) self.Find_Root self Find_Root y self self x x y y def Count(self, x):
        return -self.root[self.Find_Root(x)] Count return -self.root[self.Find_Root(x)] -self.root[self.Find_Root(x)] self.root[self.Find_Root(x)] self.root self root self.Find_Root(x) self.Find_Root self Find_Root x self self x x land = UnionFind(n) land UnionFind(n) UnionFind n all = int(n*(n-1)/2) all int(n*(n-1)/2) int n*(n-1)/2 n*(n-1) n n-1 n 1 2 lis = [all] lis [all] all for i in range(m-1):
    [a,b] = ab[-1-i]
    if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
    land.Unite(a,b)
    lis.append(all)
#print(lis) i range(m-1) range m-1 m 1 [a,b] = ab[-1-i] [a,b] a b ab[-1-i] ab -1-i -1 i if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
     land.Find_Root(a) != land.Find_Root(b) land.Find_Root(a) land.Find_Root land Find_Root a land.Find_Root(b) land.Find_Root land Find_Root b all -= land.Count(a)*land.Count(b) all land.Count(a)*land.Count(b) land.Count(a) land.Count land Count a land.Count(b) land.Count land Count b land.Unite(a,b) land.Unite land Unite a b lis.append(all) lis.append lis append all for i in range(m):
    print(lis[-1-i]) i range(m) range m print(lis[-1-i]) print lis[-1-i] lis -1-i -1 i class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)] UnionFind land = UnionFind(n) UnionFind(n) land m = map(int,input().split()) map(int,input().split()) m all -= land.Count(a)*land.Count(b) land.Count(a)*land.Count(b) all def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input all = int(n*(n-1)/2) int(n*(n-1)/2) all n,m = map(int,input().split()) map(int,input().split()) n lis = [all] [all] lis ab = [] [] ab
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m = map(int,input().split())
ab = []
for i in range(m):
     ab.append(list(map(int,input().split())))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
land = UnionFind(n)
all = int(n*(n-1)/2)
lis = [all]
for i in range(m-1):
    [a,b] = ab[-1-i]
    if land.Find_Root(a) != land.Find_Root(b):
        all -= land.Count(a)*land.Count(b)
    land.Unite(a,b)
    lis.append(all)
#print(lis)
for i in range(m):
    print(lis[-1-i])
