using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N, M;
        static int[] A, B;
        
        public static void Input()
        {
            var cin = new Solve();
            var input = cin.SplitReader();
            N = input[0];
            M = input[1];
            A = new int[M];
            B = new int[M];
            for(var i = 0; i < M; i++)
            {
                var z = cin.SplitReader();
                A[i] = z[0] - 1;
                B[i] = z[1] - 1;
            }
        }

        static void Main(string[] args)
        {
            Input();
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var u = new UnionFind(N);

            long[] ans = new long[M + 1];
            long NL = (long)N;
            ans[M] = NL * (NL - 1) / 2;
            for(var i = M - 1; i >= 0; i--)
            {
                long dif = u.SameRoot(A[i], B[i]) ? 0 : u.GetSize(A[i]) * u.GetSize(B[i]);
                u.Unite(A[i], B[i]);

                ans[i] = ans[i + 1] - dif;
            }

            for (var i = 1; i <= M; i++) 
            {
               Console.WriteLine(ans[i]);
            }
            

            Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public class UnionFind
    {
        public int[] parent;
        public int[] rank;
        public long[] size;
        public UnionFind(int n)
        {
            parent = new int[n];
            rank = new int[n];
            size = new long[n];
            for (var i = 0; i < n; i++)
            {
                parent[i] = i;
                rank[i] = 0;
                size[i] = 1;
            }
        }

        private int Root(int x)
        {
            return parent[x] == x ? x : parent[x] = Root(parent[x]);
        }

        public bool SameRoot(int x, int y)
        {
            return Root(x) == Root(y);
        }

        public void Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);
            if (x == y) { return; }

            if (rank[x] < rank[y])
            {
                parent[x] = y;
                size[y] += size[x];
                size[x] = 0;
            }
            else
            {
                parent[y] = x;
                if (rank[x] == rank[y]) { rank[x]++; }
                size[x] += size[y];
                size[y] = 0;
            }
        }

        public long GetSize(int x)
        {
            return size[Root(x)];
        }

    }

}



Measured memory_bytes: 21052