using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<int>();
            var AB = new (int a, int b)[M];
            for (var i = 0; i < M; ++i)
                AB[i] = Slice2<int>();
            var fuben = new long[M];
            fuben[M - 1] = (long)N * (N - 1) / 2;
            var uf = new UnionFind(N);
            for (var i = M - 1; 0 < i; --i)
            {
                var a = AB[i].a - 1;
                var b = AB[i].b - 1;
                var diff = 0L;
                if (!uf.issame(a, b))
                    diff = uf.size(a) * uf.size(b);
                uf.merge(a, b);
                fuben[i - 1] = fuben[i] - diff;
            }
            foreach (var f in fuben)
                WriteLine(f);
        }
        class UnionFind
        {
            int[] par;
            public UnionFind(int n)
            {
                init(n);
            }
            public void init(int n)
            {
                par = new int[n];
                for (var i = 0; i < n; ++i) { par[i] = -1; }
            }
            public int root(int x)
            {
                if (par[x] < 0) return x;
                else return par[x] = root(par[x]);
            }
            public bool issame(int x, int y)
            {
                return root(x) == root(y);
            }
            public bool merge(int x, int y)
            {
                x = root(x);
                y = root(y);
                if (x == y) return false;
                if (par[x] > par[y])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                par[x] += par[y];
                par[y] = x;
                return true;
            }
            public int size(int x)
            {
                return -par[root(x)];
            }
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 48144