using System;
using System.Collections.Generic;
using static AtCoderer.Exter;
using static System.Console;
using static System.Math;
using System.Linq;

namespace AtCoderer
{

    public class App
    {
        public static void Main(string[] args)
        {
            long n, m;
            {
                long[] r = Console.ReadLine().Split().Select(v => long.Parse(v)).ToArray();
                n = r[0];
                m = r[1];
            }
            Tuple<int, int>[] query = new Tuple<int, int>[m];
            UnionFind uf = new UnionFind((int)n);
            for (int i = 0; i < m; i++)
            {
                int[] r = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray();
                query[i] = Tuple.Create(r[0]-1,r[1]-1);
            }
            long[] UnconfortableIndex = new long[m];
            UnconfortableIndex[m - 1] = n * (n - 1) / 2;
            for (long i = m-1; i > 0; i--)
            {
                if(!uf.AreGrouped(query[i].Item1, query[i].Item2))
                    UnconfortableIndex[i - 1] = UnconfortableIndex[i] - (long)uf.GetGroupSize(query[i].Item1) * (long)uf.GetGroupSize(query[i].Item2);
                else
                    UnconfortableIndex[i - 1] = UnconfortableIndex[i];
                uf.Connect(query[i].Item1, query[i].Item2);
            }
            for(int i = 0;i<m; i++)
                Console.WriteLine(UnconfortableIndex[i]);
            Console.ReadKey();
        }
    }
    public static class Exter
    {
        public static void rep(int loop, Action<int> act)
        {
            for (int i = 0; i < loop; i++)
                act(i);
        }
        public static int ToInt(this string v) => int.Parse(v);
        public static int Max(params int[] p) => p.Max();
        public static long Max(params long[] p) => p.Max();
        public static int Min(params int[] p) => p.Min();
        public static long Min(params long[] p) => p.Min();
        public static int Gcd(int a, int b) => a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
        private static int GcdRecursive(int a, int b) => b == 0 ? a : GcdRecursive(b, a % b);
        public static object cout
        {
            set
            {
                Console.Write(value.ToString());
                Console.WriteLine();
            }
        }
        public static void ToCout<t>(this IEnumerable<t> v)
        {
            cout = string.Join(",", v);
        }
        public static string ToString(this IEnumerable<char> v)
        {
            return string.Join(",", v);
        }
        public static int[] readarr
        {
            get
            {
                return Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            }
        }
        public class UnionFind
        {
            private int[] Parent;
            private int GetRoot(int v)
            {
                if (Parent[v] < 0)
                    return v;
                else
                    return Parent[v] = GetRoot(Parent[v]);
            }
            public UnionFind(int size)
            {
                Parent = new int[size];
                for (int i = 0; i < size; i++)
                    Parent[i] = -1;
            }
            public bool AreGrouped(int a, int b)
            {
                return GetRoot(a) == GetRoot(b);
            }
            public void Connect(int a, int b)
            {
                a = GetRoot(a);
                b = GetRoot(b);
                if (a == b) return;
                Parent[b] += Parent[a];
                Parent[a] = b;
            }
            public int GetGroupSize(int a)
            {
                return -Parent[GetRoot(a)];
            }
        }
        public class TreeBuilder
        {
            public int Size;
            public List<Tuple<int, int>>[] Child;
            public TreeBuilder(int size)
            {
                Size = size;
                Child = new List<Tuple<int, int>>[size];
                for (int i = 0; i < size; i++)
                {
                    Child[i] = new List<Tuple<int, int>>();
                }
            }
            public void RegistEdge(int a, int b, int cost)
            {
                Child[a].Add(Tuple.Create(b, cost));
                Child[b].Add(Tuple.Create(a, cost));
            }
            public Tree BuildTree(int Root)
            {
                int[] Parent = new int[Size];
                Queue<int> Search = new Queue<int>();
                Search.Enqueue(Root);
                var Prev = Root;
                while (Search.Count > 0)
                {
                }
                return null;
            }
        }
        public class Tree
        {
            public int[] Parent;
            public int[] ParentDist;
            private int GetRoot(int v)
            {
                if (Parent[v] == v)
                    return v;
                else
                    return Parent[v] = GetRoot(Parent[v]);
            }
            public Tree()
            {
            }
            public void Add(int Target, int cost)
            {

            }
        }
    }
}

Measured memory_bytes: 24248