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);
        solver(input[0],input[1],input[2]);
        */
        /*
        solver(Console.ReadLine());
         */
        //solver("01101101010100100111");

        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);
        //solver(4, 5, new long[,]{{1,2},{3,4},{1,3},{2,3},{1,4}});
    }

    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]];
                }
                network[syozoku[bridge[i,1]]].AddRange(addList);
            }else{
                foreach(var tgt in network[syozoku[bridge[i,1]]]){
                    Useless -= aSize;
                    addList.Add(tgt);
                    syozoku[tgt] = syozoku[bridge[i,0]];
                }
                network[syozoku[bridge[i,0]]].AddRange(addList);
            }

            
            

        }

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


    }

    public static long lower_bound(long[] array, long input){
        var left = 0;
        var right = array.Length-1;
        var mid =0;
        while(right >= left){
            mid = left + (right - left)/2;
            if(array[mid] == input){
                return mid;
            }
            if(array[mid] > input){
                right = mid-1;
            }else{
                left = mid+1;
            }
        }

        return right;
    }

}

Measured memory_bytes: 43656