def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def size(self, x):
        return -self.parents[self.find(x)]

def cmb_1(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

cmb_list = [0] * (10 ** 5 + 1)
for i in range(10 ** 5 + 1):
    cmb_list[i] = cmb_1(i, 2)

N, M = getNM()
query = [getNM() for i in range(M)]

U = UnionFind(N)
now = cmb_list[N]
ans = [now]

for i in range(M - 1, 0, -1):
    a, b = query[i]
    size_a = 0
    size_b = 0
    if not U.same(a - 1, b - 1):
        size_a = U.size(a - 1)
        size_b = U.size(b - 1)

        U.union(a - 1, b - 1)
        size_after = U.size(a - 1)

        now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b])
    else:
        U.union(a - 1, b - 1)
    ans.append(now)

for i in range(M - 1, -1, -1):
    print(ans[i]) def getN():
    return int(input()) getN return int(input()) int(input()) int input() input def getNM():
    return map(int, input().split()) getNM return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def getList():
    return list(map(int, input().split())) getList return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def getArray(intn):
    return [int(input()) for i in range(intn)] getArray int(input()) for i in range(intn) for i in range(intn) i range(intn) range intn for i in range(intn) int(input()) int input() input return [int(input()) for i in range(intn)] [int(input()) for i in range(intn)] intn intn def input():
    return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def rand_N(ran1, ran2):
    return random.randint(ran1, ran2) rand_N return random.randint(ran1, ran2) random.randint(ran1, ran2) random.randint random randint ran1 ran2 ran1 ran1 ran2 ran2 def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] rand_List random.randint(ran1, ran2) for i in range(rantime) for i in range(rantime) i range(rantime) range rantime for i in range(rantime) random.randint(ran1, ran2) random.randint random randint ran1 ran2 return [random.randint(ran1, ran2) for i in range(rantime)] [random.randint(ran1, ran2) for i in range(rantime)] ran1 ran1 ran2 ran2 rantime rantime def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) rand_ints_nodup ns = [] ns [] while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
   len(ns) < rantime len(ns) len ns rantime n = random.randint(ran1, ran2) n random.randint(ran1, ran2) random.randint random randint ran1 ran2 if not n in ns:
      ns.append(n)
   not n in ns n in ns n ns ns.append(n) ns.append ns append n return sorted(ns) sorted(ns) sorted ns ran1 ran1 ran2 ran2 rantime rantime def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) rand_query r_query = [] r_query [] while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
   len(r_query) < rantime len(r_query) len r_query rantime n_q = rand_ints_nodup(ran1, ran2, 2) n_q rand_ints_nodup(ran1, ran2, 2) rand_ints_nodup ran1 ran2 2 if not n_q in r_query:
      r_query.append(n_q)
   not n_q in r_query n_q in r_query n_q r_query r_query.append(n_q) r_query.append r_query append n_q return sorted(r_query) sorted(r_query) sorted r_query ran1 ran1 ran2 ran2 rantime rantime from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq heapq import math math from fractions import gcd import random random import string string import copy copy from itertools import combinations, permutations, product from operator import mul from functools import reduce from bisect import bisect_left, bisect_right import sys sys sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def size(self, x):
        return -self.parents[self.find(x)] UnionFind def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

     __init__ self.n = n self.n self n n self.parents = [-1] * n self.parents self parents [-1] * n [-1] -1 n self self n n def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     find if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

     self.parents[x] < 0 self.parents[x] self.parents self parents x 0 return x x self.parents[x] = self.find(self.parents[x]) self.parents[x] self.parents self parents x self.find(self.parents[x]) self.find self find self.parents[x] self.parents self parents x return self.parents[x] self.parents[x] self.parents self parents x self self x x def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

     union 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 x == y:
            return

         x == y x y return if self.parents[x] > self.parents[y]:
            x, y = y, x

         self.parents[x] > self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y x, y = y, x x y y x self.parents[x] += self.parents[y] self.parents[x] self.parents self parents x self.parents[y] self.parents self parents y self.parents[y] = x self.parents[y] self.parents self parents y x 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 def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

     members root = self.find(x) root self.find(x) self.find self find x i for i in range(self.n) if self.find(i) == root for i in range(self.n) if self.find(i) == root i range(self.n) range self.n self n self.find(i) == root self.find(i) self.find self find i root if self.find(i) == root i return [i for i in range(self.n) if self.find(i) == root] [i for i in range(self.n) if self.find(i) == root] self self x x def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

     roots i for i, x in enumerate(self.parents) if x < 0 for i, x in enumerate(self.parents) if x < 0 i x enumerate(self.parents) enumerate self.parents self parents x < 0 x 0 if x < 0 i return [i for i, x in enumerate(self.parents) if x < 0] [i for i, x in enumerate(self.parents) if x < 0] self self def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

     all_group_members r: self.members(r) for r in self.roots() for r in self.roots() r self.roots() self.roots self roots for r in self.roots() r self.members(r) self.members self members r return {r: self.members(r) for r in self.roots()} {r: self.members(r) for r in self.roots()} self self def size(self, x):
        return -self.parents[self.find(x)] size return -self.parents[self.find(x)] -self.parents[self.find(x)] self.parents[self.find(x)] self.parents self parents self.find(x) self.find self find x self self x x def cmb_1(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under cmb_1 if n < r:
        return 0
     n < r n r return 0 0 r = min(n - r, r) r min(n - r, r) min n - r n r r if r == 0: return 1
     r == 0 r 0 over = reduce(mul, range(n, n - r, -1)) over reduce(mul, range(n, n - r, -1)) reduce mul range(n, n - r, -1) range n n - r n r -1 under = reduce(mul, range(1, r + 1)) under reduce(mul, range(1, r + 1)) reduce mul range(1, r + 1) range 1 r + 1 r 1 return over // under over // under over under n n r r cmb_list = [0] * (10 ** 5 + 1) cmb_list [0] * (10 ** 5 + 1) [0] 0 10 ** 5 + 1 10 ** 5 10 5 1 for i in range(10 ** 5 + 1):
    cmb_list[i] = cmb_1(i, 2) i range(10 ** 5 + 1) range 10 ** 5 + 1 10 ** 5 10 5 1 cmb_list[i] = cmb_1(i, 2) cmb_list[i] cmb_list i cmb_1(i, 2) cmb_1 i 2 N, M = getNM() N getNM() getNM M getNM() for i in range(M) for i in range(M) i range(M) range M for i in range(M) getNM() getNM query = [getNM() for i in range(M)] query [getNM() for i in range(M)] U = UnionFind(N) U UnionFind(N) UnionFind N now = cmb_list[N] now cmb_list[N] cmb_list N ans = [now] ans [now] now for i in range(M - 1, 0, -1):
    a, b = query[i]
    size_a = 0
    size_b = 0
    if not U.same(a - 1, b - 1):
        size_a = U.size(a - 1)
        size_b = U.size(b - 1)

        U.union(a - 1, b - 1)
        size_after = U.size(a - 1)

        now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b])
    else:
        U.union(a - 1, b - 1)
    ans.append(now) i range(M - 1, 0, -1) range M - 1 M 1 0 -1 a, b = query[i] a query[i] query i b size_a = 0 size_a 0 size_b = 0 size_b 0 if not U.same(a - 1, b - 1):
        size_a = U.size(a - 1)
        size_b = U.size(b - 1)

        U.union(a - 1, b - 1)
        size_after = U.size(a - 1)

        now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b])
    else:
        U.union(a - 1, b - 1)
     not U.same(a - 1, b - 1) U.same(a - 1, b - 1) U.same U same a - 1 a 1 b - 1 b 1 size_a = U.size(a - 1) size_a U.size(a - 1) U.size U size a - 1 a 1 size_b = U.size(b - 1) size_b U.size(b - 1) U.size U size b - 1 b 1 U.union(a - 1, b - 1) U.union U union a - 1 a 1 b - 1 b 1 size_after = U.size(a - 1) size_after U.size(a - 1) U.size U size a - 1 a 1 now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b]) now cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b] cmb_list[size_after] - cmb_list[size_a] cmb_list[size_after] cmb_list size_after cmb_list[size_a] cmb_list size_a cmb_list[size_b] cmb_list size_b U.union(a - 1, b - 1) U.union U union a - 1 a 1 b - 1 b 1 ans.append(now) ans.append ans append now for i in range(M - 1, -1, -1):
    print(ans[i]) i range(M - 1, -1, -1) range M - 1 M 1 -1 -1 print(ans[i]) print ans[i] ans i def getNM():
    return map(int, input().split()) def getNM():
    return map(int, input().split()) getNM def getArray(intn):
    return [int(input()) for i in range(intn)] def getArray(intn):
    return [int(input()) for i in range(intn)] getArray size_a = U.size(a - 1) U.size(a - 1) size_a U = UnionFind(N) UnionFind(N) U def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input size_b = U.size(b - 1) U.size(b - 1) size_b size_a = 0 0 size_a size_b = 0 0 size_b cmb_list = [0] * (10 ** 5 + 1) [0] * (10 ** 5 + 1) cmb_list def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)] rand_List def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns) rand_ints_nodup ans = [now] [now] ans def rand_N(ran1, ran2):
    return random.randint(ran1, ran2) def rand_N(ran1, ran2):
    return random.randint(ran1, ran2) rand_N a, b = query[i] query[i] a size_after = U.size(a - 1) U.size(a - 1) size_after query = [getNM() for i in range(M)] [getNM() for i in range(M)] query def getList():
    return list(map(int, input().split())) def getList():
    return list(map(int, input().split())) getList now = cmb_list[N] cmb_list[N] now mod = 10 ** 9 + 7 10 ** 9 + 7 mod now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b]) cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b] now def getN():
    return int(input()) def getN():
    return int(input()) getN class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def size(self, x):
        return -self.parents[self.find(x)] class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def size(self, x):
        return -self.parents[self.find(x)] UnionFind def cmb_1(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under def cmb_1(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under cmb_1 N, M = getNM() getNM() N def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query) rand_query M = getNM() getNM() M b = query[i] query[i] b
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def size(self, x):
        return -self.parents[self.find(x)]

def cmb_1(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

cmb_list = [0] * (10 ** 5 + 1)
for i in range(10 ** 5 + 1):
    cmb_list[i] = cmb_1(i, 2)

N, M = getNM()
query = [getNM() for i in range(M)]

U = UnionFind(N)
now = cmb_list[N]
ans = [now]

for i in range(M - 1, 0, -1):
    a, b = query[i]
    size_a = 0
    size_b = 0
    if not U.same(a - 1, b - 1):
        size_a = U.size(a - 1)
        size_b = U.size(b - 1)

        U.union(a - 1, b - 1)
        size_after = U.size(a - 1)

        now -= (cmb_list[size_after] - cmb_list[size_a] - cmb_list[size_b])
    else:
        U.union(a - 1, b - 1)
    ans.append(now)

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