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)]


n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])

all_ptn = n * (n - 1) // 2
num = 0
ret = [str(all_ptn)]

uni = UnionFind(n)
for i in range(1, m):
    a, b = ab[-i]
    prev_a = uni.Count(a)
    prev_b = uni.Count(b)
    if not uni.isSameGroup(a, b):
        uni.Unite(a, b)
        now_ab = uni.Count(a)
        cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2
        num += cnt
    ret.append(str(all_ptn - num))

ret.reverse()

print('\n'.join(ret)) 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 return x x 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 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):
    a, b = map(int, input().split())
    ab.append([a, b]) i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b ab.append([a, b]) ab.append ab append [a, b] a b all_ptn = n * (n - 1) // 2 all_ptn n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 num = 0 num 0 ret = [str(all_ptn)] ret [str(all_ptn)] str(all_ptn) str all_ptn uni = UnionFind(n) uni UnionFind(n) UnionFind n for i in range(1, m):
    a, b = ab[-i]
    prev_a = uni.Count(a)
    prev_b = uni.Count(b)
    if not uni.isSameGroup(a, b):
        uni.Unite(a, b)
        now_ab = uni.Count(a)
        cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2
        num += cnt
    ret.append(str(all_ptn - num)) i range(1, m) range 1 m a, b = ab[-i] a ab[-i] ab -i i b prev_a = uni.Count(a) prev_a uni.Count(a) uni.Count uni Count a prev_b = uni.Count(b) prev_b uni.Count(b) uni.Count uni Count b if not uni.isSameGroup(a, b):
        uni.Unite(a, b)
        now_ab = uni.Count(a)
        cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2
        num += cnt
     not uni.isSameGroup(a, b) uni.isSameGroup(a, b) uni.isSameGroup uni isSameGroup a b uni.Unite(a, b) uni.Unite uni Unite a b now_ab = uni.Count(a) now_ab uni.Count(a) uni.Count uni Count a cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2 cnt now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2 now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 now_ab * (now_ab - 1) // 2 now_ab * (now_ab - 1) now_ab now_ab - 1 now_ab 1 2 (prev_a * (prev_a - 1)) // 2 prev_a * (prev_a - 1) prev_a prev_a - 1 prev_a 1 2 (prev_b * (prev_b - 1)) // 2 prev_b * (prev_b - 1) prev_b prev_b - 1 prev_b 1 2 num += cnt num cnt ret.append(str(all_ptn - num)) ret.append ret append str(all_ptn - num) str all_ptn - num all_ptn num ret.reverse() ret.reverse ret reverse print('\n'.join(ret)) print '\n'.join(ret) '\n'.join '\n' join ret num = 0 0 num b = map(int, input().split()) map(int, input().split()) b b = ab[-i] ab[-i] b m = map(int, input().split()) map(int, input().split()) m all_ptn = n * (n - 1) // 2 n * (n - 1) // 2 all_ptn a, b = ab[-i] ab[-i] a ret = [str(all_ptn)] [str(all_ptn)] ret prev_b = uni.Count(b) uni.Count(b) prev_b ab = [] [] ab uni = UnionFind(n) UnionFind(n) uni num += cnt cnt num n, m = map(int, input().split()) map(int, input().split()) n a, b = map(int, input().split()) map(int, input().split()) a cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2 now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2 cnt prev_a = uni.Count(a) uni.Count(a) prev_a now_ab = uni.Count(a) uni.Count(a) now_ab 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
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)]


n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])

all_ptn = n * (n - 1) // 2
num = 0
ret = [str(all_ptn)]

uni = UnionFind(n)
for i in range(1, m):
    a, b = ab[-i]
    prev_a = uni.Count(a)
    prev_b = uni.Count(b)
    if not uni.isSameGroup(a, b):
        uni.Unite(a, b)
        now_ab = uni.Count(a)
        cnt = now_ab * (now_ab - 1) // 2 - (prev_a * (prev_a - 1)) // 2 - \
            (prev_b * (prev_b - 1)) // 2
        num += cnt
    ret.append(str(all_ptn - num))

ret.reverse()

print('\n'.join(ret))
