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

namespace AtCoder
{
    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static IEnumerable<long> Solve(int N, int M, int[][] bridges)
        {
            var values = new long[M];
            var nodes = new Node<int>[N];
            var areas = new int[N];
            for (int i = 0; i < N; ++i)
            {
                nodes[i] = new Node<int>(i);
                areas[i] = 1;
            }
            long sum = Math.BigMul(N, N - 1) / 2;
            for (int i = M - 1; i >= 0; --i)
            {
                values[i] = sum;
                int a = bridges[i][0];
                int b = bridges[i][1];
                int A = nodes[a].Find().Item;
                int B = nodes[b].Find().Item;
                if (A != B)
                {
                    int l = areas[A];
                    int r = areas[B];
                    Node<int>.Unite(nodes[a], nodes[b]);
                    int p = nodes[a].Find().Item;
                    areas[p] = l + r;
                    sum -= Math.BigMul(l, r);
                }
            }
            return values;
        }

        static void Main(string[] args)
        {
            int[] V1 = ReadInts();
            int N = V1[0], M = V1[1];
            var bridges = new int[M][];
            for (int i = 0; i < M; ++i)
            {
                int[] V2 = ReadInts();
                bridges[i] = new[] { V2[0] - 1, V2[1] - 1 };
            }
            foreach (var ans in Solve(N, M, bridges))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 28700