n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

li = li[::-1]
lin = []
uni = UnionFind(n)
now = n*(n-1)//2
lin.append(now)

for i in range(1,m):
    a,b = li[i-1]
    a -= 1
    b -= 1
    if uni.same(a,b):
        lin.append(lin[-1])
    else:
        lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)])
    uni.union(a,b)

lin = lin[::-1]

for i in lin:
    print(i) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split li = [list(map(int,input().split())) for _ in range(m)] li [list(map(int,input().split())) for _ in range(m)] class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n) UnionFind def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
     __init__ i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i self.par = [i for i in range(n)] self.par self par [i for i in range(n)] self.rank = [0] * n self.rank self rank [0] * n [0] 0 n self.size = [1] * n self.size self size [1] * n [1] 1 n self self n n def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
     find if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
     self.par[x] == x self.par[x] self.par self par x x 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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
     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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
     self.rank[x] < self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.par[x] = y self.par[x] self.par self par x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x self.par[y] = x self.par[y] self.par self par y x self.size[x] += self.size[y] self.size[x] self.size self size x self.size[y] self.size self size y if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
     self.rank[x] == self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y self.rank[x] += 1 self.rank[x] self.rank self rank x 1 self self x x y y 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 all_find(self):
        for n in range(len(self.par)):
            self.find(n) all_find for n in range(len(self.par)):
            self.find(n) n range(len(self.par)) range len(self.par) len self.par self par self.find(n) self.find self find n self self li = li[::-1] li li[::-1] li ::-1 -1 lin = [] lin [] uni = UnionFind(n) uni UnionFind(n) UnionFind n now = n*(n-1)//2 now n*(n-1)//2 n*(n-1) n n-1 n 1 2 lin.append(now) lin.append lin append now for i in range(1,m):
    a,b = li[i-1]
    a -= 1
    b -= 1
    if uni.same(a,b):
        lin.append(lin[-1])
    else:
        lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)])
    uni.union(a,b) i range(1,m) range 1 m a,b = li[i-1] a li[i-1] li i-1 i 1 b a -= 1 a 1 b -= 1 b 1 if uni.same(a,b):
        lin.append(lin[-1])
    else:
        lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)])
     uni.same(a,b) uni.same uni same a b lin.append(lin[-1]) lin.append lin append lin[-1] lin -1 lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)]) lin.append lin append lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)] lin[-1] lin -1 uni.size[uni.find(a)]*uni.size[uni.find(b)] uni.size[uni.find(a)] uni.size uni size uni.find(a) uni.find uni find a uni.size[uni.find(b)] uni.size uni size uni.find(b) uni.find uni find b uni.union(a,b) uni.union uni union a b lin = lin[::-1] lin lin[::-1] lin ::-1 -1 for i in lin:
    print(i) i lin print(i) print i n,m = map(int,input().split()) map(int,input().split()) n class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n) class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n) UnionFind lin = [] [] lin lin = lin[::-1] lin[::-1] lin m = map(int,input().split()) map(int,input().split()) m uni = UnionFind(n) UnionFind(n) uni a,b = li[i-1] li[i-1] a li = li[::-1] li[::-1] li b = li[i-1] li[i-1] b now = n*(n-1)//2 n*(n-1)//2 now li = [list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] li b -= 1 1 b a -= 1 1 a
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            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.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

li = li[::-1]
lin = []
uni = UnionFind(n)
now = n*(n-1)//2
lin.append(now)

for i in range(1,m):
    a,b = li[i-1]
    a -= 1
    b -= 1
    if uni.same(a,b):
        lin.append(lin[-1])
    else:
        lin.append(lin[-1]-uni.size[uni.find(a)]*uni.size[uni.find(b)])
    uni.union(a,b)

lin = lin[::-1]

for i in lin:
    print(i)