import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    uf = UnionFindTree(N)
    mx = N*(N-1)//2
    ans = [mx]*M
    for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

    for a in ans: print(a)

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)]


if __name__ == '__main__':
    main() import sys sys def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    uf = UnionFindTree(N)
    mx = N*(N-1)//2
    ans = [mx]*M
    for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

    for a in ans: print(a) main input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N,M=map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) tuple(map(lambda x:int(x)-1, input().split())) tuple map(lambda x:int(x)-1, input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)] AB [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)] uf = UnionFindTree(N) uf UnionFindTree(N) UnionFindTree N mx = N*(N-1)//2 mx N*(N-1)//2 N*(N-1) N N-1 N 1 2 ans = [mx]*M ans [mx]*M [mx] mx M for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

     i range(M-1,0,-1) range M-1 M 1 0 -1 a,b = AB[i] a AB[i] AB i b ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b)) ans[i-1] ans i-1 i 1 ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b)) ans[i] ans i 0 if uf.same(a, b) else uf.size(a)*uf.size(b) uf.same(a, b) uf.same uf same a b 0 uf.size(a)*uf.size(b) uf.size(a) uf.size uf size a uf.size(b) uf.size uf size b uf.union(a, b) uf.union uf union a b for a in ans: prin a ans class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)] UnionFindTree def __init__(self, n):
        self.parent = [-1] * n

     __init__ self.parent = [-1] * n self.parent self parent [-1] * n [-1] -1 n self self n n def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

     find p = self.parent p self.parent self parent while p[x] >= 0: x, p[x] = p[x], p[p[x]]
         p[x] >= 0 p[x] p x 0 return x x self self x x def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

     union x, y, p = self.find(x), self.find(y), self.parent x self.find(x) self.find self find x y self.find(y) self.find self find y p self.parent self parent if x == y: return
         x == y x y if p[x] > p[y]: x, y = y, x
         p[x] > p[y] p[x] p x p[y] p y p[x], p[y] = p[x] + p[y], x p[x] p x p[x] + p[y] p[x] p x p[y] p y p[y] p y x self self x x y y def same(self, x, y): return self.find(x) == self.find(y)
     same self self x x y y def size(self, x): return -self.parent[self.find size self self x x if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)] class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)] UnionFindTree def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    uf = UnionFindTree(N)
    mx = N*(N-1)//2
    ans = [mx]*M
    for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

    for a in ans: print(a) def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    uf = UnionFindTree(N)
    mx = N*(N-1)//2
    ans = [mx]*M
    for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

    for a in ans: print(a) main
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    AB=[tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]

    uf = UnionFindTree(N)
    mx = N*(N-1)//2
    ans = [mx]*M
    for i in range(M-1,0,-1):
        a,b = AB[i]
        ans[i-1] = ans[i] - (0 if uf.same(a, b) else uf.size(a)*uf.size(b))
        uf.union(a, b)

    for a in ans: print(a)

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)]


if __name__ == '__main__':
    main()