class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ans = [int(n * (n - 1) / 2) for i in range(m)]
uni = UnionFind(n)

for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1]


for i in range(1, m+1):
    print(ans[-i]) class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True UnionFind Parents = None Parents None def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
     __init__ -1 for i in range(N + 1) for i in range(N + 1) i range(N + 1) range N + 1 N 1 for i in range(N + 1) -1 self.Parents = [-1 for i in range(N + 1)] self.Parents self Parents [-1 for i in range(N + 1)] self self N N def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
     root if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
     self.Parents[A] < 0 self.Parents[A] self.Parents self Parents A 0 return A A self.Parents[A] = self.root(self.Parents[A]) self.Parents[A] self.Parents self Parents A self.root(self.Parents[A]) self.root self root self.Parents[A] self.Parents self Parents A return self.Parents[A] self.Parents[A] self.Parents self Parents A self self A A def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
     size return -self.Parents[self.root(A)] -self.Parents[self.root(A)] self.Parents[self.root(A)] self.Parents self Parents self.root(A) self.root self root A self self A A def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True Connect if self.root(A) == self.root(B):
            return False
         self.root(A) == self.root(B) self.root(A) self.root self root A self.root(B) self.root self root B return False False if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
         self.size(A) < self.size(B) self.size(A) self.size self size A self.size(B) self.size self size B self.Parents[self.root(B)] += self.Parents[self.root(A)] self.Parents[self.root(B)] self.Parents self Parents self.root(B) self.root self root B self.Parents[self.root(A)] self.Parents self Parents self.root(A) self.root self root A self.Parents[self.root(A)] = B self.Parents[self.root(A)] self.Parents self Parents self.root(A) self.root self root A B self.Parents[self.root(A)] += self.Parents[self.root(B)] self.Parents[self.root(A)] self.Parents self Parents self.root(A) self.root self root A self.Parents[self.root(B)] self.Parents self Parents self.root(B) self.root self root B self.Parents[self.root(B)] = A self.Parents[self.root(B)] self.Parents self Parents self.root(B) self.root self root B A return True True self self A A B B n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m input().split() for i in range(m) for i in range(m) i range(m) range m for i in range(m) input().split() ().split () input split a = [input().split() for i in range(m)] a [input().split() for i in range(m)] (int(i[0]), int(i[1])) for i in a for i in a i a for i in a (int(i[0]), int(i[1])) int(i[0]) int i[0] i 0 int(i[1]) int i[1] i 1 a = [(int(i[0]), int(i[1])) for i in a] a [(int(i[0]), int(i[1])) for i in a] int(n * (n - 1) / 2) for i in range(m) for i in range(m) i range(m) range m for i in range(m) int(n * (n - 1) / 2) int n * (n - 1) / 2 n * (n - 1) n n - 1 n 1 2 ans = [int(n * (n - 1) / 2) for i in range(m)] ans [int(n * (n - 1) / 2) for i in range(m)] uni = UnionFind(n) uni UnionFind(n) UnionFind n for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1] i range(m) range m if i == 0:
        continue
     i == 0 i 0 continue A = a[-i][0] A a[-i][0] [-i] a -i i 0 B = a[-i][1] B a[-i][1] [-i] a -i i 1 if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1] uni.root(A) != uni.root(B) uni.root(A) uni.root uni root A uni.root(B) uni.root uni root B ans[i] = ans[i-1] - uni.size(A) * uni.size(B) ans[i] ans i ans[i-1] - uni.size(A) * uni.size(B) ans[i-1] ans i-1 i 1 uni.size(A) * uni.size(B) uni.size(A) uni.size uni size A uni.size(B) uni.size uni size B uni.Connect(A, B) uni.Connect uni Connect A B ans[i] = ans[i-1] ans[i] ans i ans[i-1] ans i-1 i 1 for i in range(1, m+1):
    print(ans[-i]) i range(1, m+1) range 1 m+1 m 1 print(ans[-i]) print ans[-i] ans -i i a = [input().split() for i in range(m)] [input().split() for i in range(m)] a n, m = map(int, input().split()) map(int, input().split()) n B = a[-i][1] a[-i][1] B a = [(int(i[0]), int(i[1])) for i in a] [(int(i[0]), int(i[1])) for i in a] a A = a[-i][0] a[-i][0] A class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True UnionFind ans = [int(n * (n - 1) / 2) for i in range(m)] [int(n * (n - 1) / 2) for i in range(m)] ans m = map(int, input().split()) map(int, input().split()) m uni = UnionFind(n) UnionFind(n) uni
class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ans = [int(n * (n - 1) / 2) for i in range(m)]
uni = UnionFind(n)

for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1]


for i in range(1, m+1):
    print(ans[-i])
