import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

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

d = [0]*m
uf = UnionFind(n)
for i in range(m-1,-1,-1):
    a,b = path[i]
    if not uf.same(a,b):
        d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)]
    uf.unite(a,b)
s = [0]*(m+1)
for i in range(m):
    s[i+1] = s[i] + d[i]
print('\n'.join(str(i) for i in s[1:])) import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
     __init__ '木の初期化をする' self.p = [-1] * n self.p self p [-1] * n [-1] -1 n self.rank = [1]*n self.rank self rank [1]*n [1] 1 n self.size = [1]*n self.size self size [1]*n [1] 1 n self self n n def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

     find 'x の親を返す' if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

     self.p[x] == -1 self.p[x] self.p self p x -1 return x x self.p[x] = self.find(self.p[x]) self.p[x] self.p self p x self.find(self.p[x]) self.find self find self.p[x] self.p self p x return self.p[x] self.p[x] self.p self p x self self x x def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

     unite 'rankの低い親を高い方のの親にする' if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

     not self.same(x,y) self.same(x,y) self.same self same x y 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 self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
             self.rank[x] > self.rank[y] self.rank[x] self.rank self rank x self.rank[y] self.rank self rank y x,y = y,x x y y x elif self.rank[x] == self.rank[y]:
                self.rank[y] += 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[y] += 1 self.rank[y] self.rank self rank y 1 self.p[x] = y self.p[x] self.p self p x y self.size[y] += self.size[x] self.size[y] self.size self size y self.size[x] self.size self size x return True True return False False 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 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m path = [] path [] for i in range(m):
    a,b = map(int,input().split())
    path.append((a-1,b-1)) i range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b path.append((a-1,b-1)) path.append path append (a-1,b-1) a-1 a 1 b-1 b 1 d = [0]*m d [0]*m [0] 0 m uf = UnionFind(n) uf UnionFind(n) UnionFind n for i in range(m-1,-1,-1):
    a,b = path[i]
    if not uf.same(a,b):
        d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)]
    uf.unite(a,b) i range(m-1,-1,-1) range m-1 m 1 -1 -1 a,b = path[i] a path[i] path i b if not uf.same(a,b):
        d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)]
     not uf.same(a,b) uf.same(a,b) uf.same uf same a b d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)] d[i] d i uf.size[uf.find(a)]*uf.size[uf.find(b)] uf.size[uf.find(a)] uf.size uf size uf.find(a) uf.find uf find a uf.size[uf.find(b)] uf.size uf size uf.find(b) uf.find uf find b uf.unite(a,b) uf.unite uf unite a b s = [0]*(m+1) s [0]*(m+1) [0] 0 m+1 m 1 for i in range(m):
    s[i+1] = s[i] + d[i] i range(m) range m s[i+1] = s[i] + d[i] s[i+1] s i+1 i 1 s[i] + d[i] s[i] s i d[i] d i print('\n'.join(str(i) for i in s[1:])) print '\n'.join(str(i) for i in s[1:]) '\n'.join '\n' join str(i) str i s = [0]*(m+1) [0]*(m+1) s input = sys.stdin.readline sys.stdin.readline input b = path[i] path[i] b class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y) class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y) UnionFind path = [] [] path m = map(int,input().split()) map(int,input().split()) m b = map(int,input().split()) map(int,input().split()) b a,b = path[i] path[i] a n,m = map(int,input().split()) map(int,input().split()) n a,b = map(int,input().split()) map(int,input().split()) a d = [0]*m [0]*m d uf = UnionFind(n) UnionFind(n) uf
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

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

d = [0]*m
uf = UnionFind(n)
for i in range(m-1,-1,-1):
    a,b = path[i]
    if not uf.same(a,b):
        d[i] = uf.size[uf.find(a)]*uf.size[uf.find(b)]
    uf.unite(a,b)
s = [0]*(m+1)
for i in range(m):
    s[i+1] = s[i] + d[i]
print('\n'.join(str(i) for i in s[1:]))
