using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var N = line[0];
            var M = line[1];
            var ab = consoleReader.RepeatSplitInt32(M).ToArray();
            var result = new long[M];
            var group = new int[N];
            var groupList = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
            var groupId = 0;

            result[M - 1] = (long)N * (N - 1) / 2;
            for (int i = M - 1; i > 0; i--)
            {
                var a = ab[i][0] - 1;
                var b = ab[i][1] - 1;

                var groupA = group[a];
                var groupB = group[b];

                long num;

                if (groupA == 0 && groupB == 0)
                {
                    num = 1;
                    group[a] = group[b] = ++groupId;
                    groupList[groupId].Add(a);
                    groupList[groupId].Add(b);
                }
                else if (groupA == 0)
                {
                    num = groupList[groupB].Count;
                    groupList[groupB].Add(a);
                    group[a] = groupB;
                }
                else if (groupB == 0)
                {
                    num = groupList[groupA].Count;
                    groupList[groupA].Add(b);
                    group[b] = groupA;
                }
                else if (groupA != groupB)
                {
                    num = (long)groupList[groupA].Count * groupList[groupB].Count;
                    if (groupList[groupA].Count > groupList[groupB].Count)
                        foreach (var g in groupList[groupB])
                        {
                            groupList[groupA].Add(g);
                            group[g] = groupA;
                        }
                    else
                        foreach (var g in groupList[groupA])
                        {
                            groupList[groupB].Add(g);
                            group[g] = groupB;
                        }
                }
                else
                {
                    num = 0;
                }

                result[i - 1] = result[i] - num;
            }

            return MultiLine(result);
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


Measured memory_bytes: 45552