using System;
using System.Collections.Generic;
using System.Linq;

public class S
{



    public static void Main()
	{

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        var bridge = new long[M,2];
        for(int i = 0; i < M; i++){
            input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            bridge[i,0] = input[0];
            bridge[i,1] = input[1];
        }
        solver(N,M,bridge);
    }

    public static void solver(long N, long M, long[,] bridge){

        long Useless = 0;
        long networkCnt = 0;
        var network = new Dictionary<long, List<long>>();
        var syozoku = new Dictionary<long, long>();
        var addList = new List<long>();
        var answers = new long[M];
        for(long i = N-1; i > 0; i--){
            Useless += i;
        }

        long tmpCount;

        for(long i = M-1; i >=0; i--){
            answers[i] = Useless;
            addList.Clear();
            tmpCount = 0;
            // 両方新規：ネットワークが1本立つ
            if(!syozoku.ContainsKey(bridge[i,0]) && !syozoku.ContainsKey(bridge[i,1])){
                networkCnt++;
                network[networkCnt] = new List<long>();
                network[networkCnt].Add(bridge[i,0]);
                network[networkCnt].Add(bridge[i,1]);
                syozoku.Add(bridge[i,0], networkCnt);
                syozoku.Add(bridge[i,1], networkCnt);
                Useless--;
                continue;
            }

            // aが新規：bの所属ネットに追加
            if(!syozoku.ContainsKey(bridge[i,0])){
                tmpCount = network[syozoku[bridge[i,1]]].Count();
                network[syozoku[bridge[i,1]]].Add(bridge[i,0]);
                syozoku[bridge[i,0]] = syozoku[bridge[i,1]];
                Useless -= tmpCount;
                continue;
            }

            // b画新規：aの所属ネットに追加
            if(!syozoku.ContainsKey(bridge[i,1])){
                tmpCount = network[syozoku[bridge[i,0]]].Count();
                network[syozoku[bridge[i,0]]].Add(bridge[i,1]);
                syozoku[bridge[i,1]] = syozoku[bridge[i,0]];
                Useless -= tmpCount;
                continue;
            }

            // 両方ネットワークに所属している場合

            // どちらも同じネットワークに所属している場合は何もしない。何も変わらないし。
            if(syozoku[bridge[i,0]] == syozoku[bridge[i,1]]) continue;

            // 所属ネットワークが異なる場合
            long aSize = network[syozoku[bridge[i,0]]].Count();
            long bSize = network[syozoku[bridge[i,1]]].Count();

            if(aSize < bSize){
                foreach(var tgt in network[syozoku[bridge[i,0]]]){
                    Useless -= bSize;
                    addList.Add(tgt);
                    syozoku[tgt] = syozoku[bridge[i,1]];
                }
                foreach(var tgt in addList){
                    network[syozoku[bridge[i,1]]].Add(tgt);
                }
                
            }else{
                foreach(var tgt in network[syozoku[bridge[i,1]]]){
                    Useless -= aSize;
                    addList.Add(tgt);
                    syozoku[tgt] = syozoku[bridge[i,0]];
                }
                foreach(var tgt in addList){
                    network[syozoku[bridge[i,0]]].Add(tgt);
                }
            }

            
            

        }

        foreach(var tgt in answers){
            Console.WriteLine(tgt);
        }


    }

}

Measured memory_bytes: 39680