#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;
 
 
fn main() {
    let line = read_vector::<usize>();
    let (n, m) = (line[0], line[1]);
    let mut bridge = vec![];
    for i in 0..m {
        let line = read_vector::<usize>();
        if i == 0 {
            continue;
        }
        bridge.push((line[0] - 1, line[1] - 1));
    }
    let mut ans = vec![(n * (n - 1)) / 2];
    let mut union_find = UnionFindTree::new(n);
    for &(i, j) in bridge.iter().rev() {
        if union_find.is_same_group(i, j) {
            let last_ans = ans[ans.len() - 1];
            ans.push(last_ans);
            continue;
        }
        let i_size = union_find.size(i);
        let j_size = union_find.size(j);
        union_find.union(i, j);
        let last_ans = ans[ans.len() - 1];
        if last_ans == 0 {
            ans.push(0);
        } else {
            ans.push(last_ans - i_size * j_size);
        }
    }
    for &num in ans.iter().rev() {
        println!("{}", num);
    }
}
 
#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}
 
struct UnionFindTree {
    parents: Vec<usize>,
    heights: Vec<usize>,
    sizes: Vec<usize>,
}

impl UnionFindTree {
    fn new(size: usize) -> UnionFindTree {
        UnionFindTree{parents: (0..size).collect(), heights: vec![0; size], sizes: vec![1; size]}
    }

    fn climb_up(&mut self, node: usize) -> usize {
        let mut parents_to_root = vec![node];
        let mut present = node;

        loop {
            if self.parents[present] == present {
                for node in parents_to_root.iter() {
                    self.parents[*node] = present;
                }
                return present;
            }
            present = self.parents[present];
            parents_to_root.push(present);
        }
    }

    fn is_same_group(&mut self, x: usize, y: usize) -> bool {
        self.climb_up(x) == self.climb_up(y)
    }

    fn union(&mut self, x: usize, y: usize) {
        let root_x = self.climb_up(x);
        let root_y = self.climb_up(y);

        if root_x == root_y {
            return;
        }

        if self.heights[root_x] > self.heights[root_y] {
            self.parents[root_y] = root_x;
            self.sizes[root_x] += self.sizes[root_y];
        } else if self.heights[root_x] < self.heights[root_y] {
            self.parents[root_x] = root_y;
            self.sizes[root_y] += self.sizes[root_x];
        } else {
            self.parents[root_y] = root_x;
            self.heights[root_x] += 1;
            self.sizes[root_x] += self.sizes[root_y];
        }
    }

    fn size(&mut self, x: usize) -> usize {
        let root = self.climb_up(x);
        self.sizes[root]
    }
    
}


#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}
 
#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();
 
    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }
 
    return matrix;
}
 
#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}

Measured memory_bytes: 11516