import sys

class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1



def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    B = [[int(a) - 1 for a in input().split()] for _ in range(M)]
    parent = UFT(N)

    Ans = [N * (N - 1) // 2] * M
    for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve() import sys sys class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1 UFT def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

     __init__ int(i) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(i) int i self.tree = [int(i) for i in range(N)] self.tree self tree [int(i) for i in range(N)] 0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 0 self.rank = [0 for i in range(N)] self.rank self rank [0 for i in range(N)] self.size = [1] * N self.size self size [1] * N [1] 1 N self self N N def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

     find if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

     self.tree[a] == a self.tree[a] self.tree self tree a a self.tree[a] = self.find(self.tree[a]) self.tree[a] self.tree self tree a self.find(self.tree[a]) self.find self find self.tree[a] self.tree self tree a return self.tree[a] self.tree[a] self.tree self tree a self self a a def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

     findSize self.tree[a] = self.find(a) self.tree[a] self.tree self tree a self.find(a) self.find self find a self.size[a] = self.size[self.tree[a]] self.size[a] self.size self size a self.size[self.tree[a]] self.size self size self.tree[a] self.tree self tree a return self.size[a] self.size[a] self.size self size a self self a a def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1 unite a = self.find(a) a self.find(a) self.find self find a b = self.find(b) b self.find(b) self.find self find b asize = self.size[a] asize self.size[a] self.size self size a bsize = self.size[b] bsize self.size[b] self.size self size b if a == b: return
         a == b a b if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1 self.rank[a] < self.rank[b] self.rank[a] self.rank self rank a self.rank[b] self.rank self rank b self.tree[a] = b self.tree[a] self.tree self tree a b self.size[b] += asize self.size[b] self.size self size b asize self.tree[b] = a self.tree[b] self.tree self tree b a self.size[a] += bsize self.size[a] self.size self size a bsize if self.rank[a] == self.rank[b]: self. self.rank[a] == self.rank[b] self.rank[a] self.rank self rank a self.rank[b] self.rank self rank b self self a a b b def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    B = [[int(a) - 1 for a in input().split()] for _ in range(M)]
    parent = UFT(N)

    Ans = [N * (N - 1) // 2] * M
    for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
    print("\n".join(map(str, Ans)))

    return 0 solve 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 [int(a) - 1 for a in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(a) - 1 for a in input().split()] B = [[int(a) - 1 for a in input().split()] for _ in range(M)] B [[int(a) - 1 for a in input().split()] for _ in range(M)] parent = UFT(N) parent UFT(N) UFT N Ans = [N * (N - 1) // 2] * M Ans [N * (N - 1) // 2] * M [N * (N - 1) // 2] N * (N - 1) // 2 N * (N - 1) N N - 1 N 1 2 M for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
     i reversed(range(1, M)) reversed range(1, M) range 1 M x, y = B[i] x B[i] B i y if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
     parent.find(x) != parent.find(y) parent.find(x) parent.find parent find x parent.find(y) parent.find parent find y xsize = parent.findSize(x) xsize parent.findSize(x) parent.findSize parent findSize x ysize = parent.findSize(y) ysize parent.findSize(y) parent.findSize parent findSize y parent.unite(x, y) parent.unite parent unite x y Ans[i - 1] = Ans[i] - (xsize * ysize) Ans[i - 1] Ans i - 1 i 1 Ans[i] - (xsize * ysize) Ans[i] Ans i xsize * ysize xsize ysize Ans[i-1] = Ans[i] Ans[i-1] Ans i-1 i 1 Ans[i] Ans i print("\n".join(map(str, Ans))) print "\n".join(map(str, Ans)) "\n".join "\n" join map(str, Ans) map str Ans return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    B = [[int(a) - 1 for a in input().split()] for _ in range(M)]
    parent = UFT(N)

    Ans = [N * (N - 1) // 2] * M
    for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
    print("\n".join(map(str, Ans)))

    return 0 def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    B = [[int(a) - 1 for a in input().split()] for _ in range(M)]
    parent = UFT(N)

    Ans = [N * (N - 1) // 2] * M
    for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
    print("\n".join(map(str, Ans)))

    return 0 solve class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1 class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1 UFT
import sys

class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]
        self.size = [1] * N

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def findSize(self, a):
        self.tree[a] = self.find(a)
        self.size[a] = self.size[self.tree[a]]
        return self.size[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        asize = self.size[a]
        bsize = self.size[b]
        if a == b: return
        if self.rank[a] < self.rank[b]: 
            self.tree[a] = b
            self.size[b] += asize
        else:
            self.tree[b] = a
            self.size[a] += bsize
            if self.rank[a] == self.rank[b]: self.rank[a] += 1



def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    B = [[int(a) - 1 for a in input().split()] for _ in range(M)]
    parent = UFT(N)

    Ans = [N * (N - 1) // 2] * M
    for i in reversed(range(1, M)):
        x, y = B[i]
        if parent.find(x) != parent.find(y):
            xsize = parent.findSize(x)
            ysize = parent.findSize(y)
            parent.unite(x, y)
            Ans[i - 1] = Ans[i] - (xsize * ysize)
        else:
            Ans[i-1] = Ans[i]
    print("\n".join(map(str, Ans)))

    return 0

if __name__ == "__main__":
    solve()