using System;
using System.Collections.Generic;
using atcorder.DataStructure;
namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }


    public class Test
    {
        public static void Run()
        {
            List<List<int>> Group = new List<List<int>>();
            Input input = new Input(' ');
            input.ReadLine();
            int N = input.Next<int>();
            int M = input.Next<int>();
            List<Pair<int, int>> edges = new List<Pair<int, int>>();
            List<long> cnt = new List<long>();
            for (int i = 0; i < M; i++)
            {
                input.ReadLine();
                Pair<int, int> pair = new Pair<int, int>();
                pair.first = input.Next<int>();
                pair.second = input.Next<int>();
                edges.Add(new Pair<int, int>(pair));
            }
            UnionFind unionfind = new UnionFind(N);
            for (int i = M - 1; i >= 0; i--)
            {
                if (unionfind.Same(edges[i].first, edges[i].second)) cnt.Add(0);
                else{
                    cnt.Add((long)unionfind.Size(edges[i].first) * unionfind.Size(edges[i].second));
                    unionfind.Unite(edges[i].first, edges[i].second);
                }
            }
            cnt.Reverse();
            long c = 0;
            foreach (long l in cnt)
            {
                c += l;
                Console.WriteLine(c);
            }
        }
    }







    public class Input
    {
        int arg;
        int length;
        string s;
        string[] ss;
        char sep;
        public Input(char _sep = '\0')
        {
            sep = _sep;
        }
        public void ReadLine()
        {
            s = Console.ReadLine();
            if (sep != '\0') ss = s.Split(sep);
            else
            {
                ss = new string[1];
                ss[0] = s;
            }
            arg = 0;
            length = ss.Length;
        }
        public T Next<T>()
        {
            if (arg == length) throw new IndexOutOfRangeException();
            return (T)Convert.ChangeType(ss[arg++], typeof(T));
        }
        public void SetSeparater(char _sep)
        {
            sep = _sep;
        }
    }
      namespace DataStructure{
        public class Pair<S,T>{
            public Pair(){}
            public Pair(S f,T s){
                first = f;
                second = s;
            }
            public Pair(Pair<S,T> p){
                first = p.first;
                second = p.second;
            }
            public S first;
            public T second;
        }

        public class Tree{
            public class Node{
                public int Id;
                public object Value;
                public Node Parent;
                public List<Node> Children = new List<Node>();
                public Node GetRoot(){
                    if (Parent == null) return this;
                    else return Parent.GetRoot();
                }
            }
            public Node AddNode(Node parent, Node child){
                child.Parent = parent;
                parent.Children.Add(child);
                return child;
            }
        }
        public class UnionFind : Tree{
            private List<int> rank = new List<int>();
                
            private List<Node> nodes = new List<Node>();
            public UnionFind(int n){
                for (int i = 1; i <= n;i++){
                    Node node = new Node();
                    node.Id = i;
                    node.Value = 1;
                    nodes.Add(node);
                    rank.Add(1);
                }
            }
            /// <summary>
            /// aを含む集合とbを含む集合を連結す
            /// </summary>
            public void Unite(int a,int b){
                Node ra = nodes[a-1].GetRoot();
                Node rb = nodes[b-1].GetRoot();
                if (ra.Id == rb.Id) return;
                if(rank[ra.Id-1]>rank[rb.Id - 1]){
                    ra.Value = (int)ra.Value + (int)rb.Value;
                    rb.Parent = ra;
                    rank[ra.Id - 1]++;
                }else{
                    rb.Value = (int)ra.Value + (int)rb.Value;
                    ra.Parent = rb;
                    rank[rb.Id - 1]++;
                }
            }
            /// <summary>
            /// aとbが同じ集合に含まれているかを返す
            /// </summary>
            public bool Same(int a,int b){
                return nodes[a-1].GetRoot().Id == nodes[b-1].GetRoot().Id;
            }
            ///<summary>
            /// aを含む集合のサイズを返す
            /// </summary>
            public int Size(int a){
                return (int)nodes[a-1].GetRoot().Value;
            }
        }
    }
}


Measured memory_bytes: 38688