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

public class Program
{
    public static void Main(string[] args)
    {
        var NM = Scanner.StringList;
        int N = NM[0].Int();
        int M = NM[1].Int();

        int[] A = new int[M];
        int[] B = new int[M];
        foreach(int i in Enumerable.Range(0, M))
        {
            var AB = Scanner.StringList;
            A[i] = AB[0].Int();
            B[i] = AB[1].Int();
        }

        UnionFind unionFind = new UnionFind(N + 1);

        long[] R = new long[M]; R[M - 1] = N.Factorial(2) / 2;

        foreach (int i in Enumerable.Range(0, M).Reverse().Skip(1))
        {
            int AI = A[i + 1];
            int BI = B[i + 1];

            R[i] = R[i + 1];

            if (!unionFind.Same(AI, BI))
            {
                int AS = unionFind.Size(AI);
                int BS = unionFind.Size(BI);

                R[i] -= (long)AS * BS;

                unionFind.Unite(AI, BI);
            }
        }

        foreach (int i in Enumerable.Range(0, M))
        {
            Console.WriteLine(R[i]);
        }

        Console.ReadLine();
    }
}

/// <summary>
/// スキャナ
/// </summary>
public class Scanner
{
    public static long Long
    {
        get
        {
            return Console.ReadLine().Long();
        }
    }

    public static int Int
    {
        get
        {
            return Console.ReadLine().Int();
        }
    }

    public static string String
    {
        get
        {
            return Console.ReadLine();
        }
    }

    public static string[] StringList
    {
        get
        {
            return Console.ReadLine().Split();
        }
    }

    public static IEnumerable<int> IntList
    {
        get
        {
            return StringList.Select(int.Parse);
        }
    }

    public static IEnumerable<long> LongList
    {
        get
        {
            return StringList.Select(long.Parse);
        }
    }

    public static IEnumerable<double> DoubleList
    {
        get
        {
            return StringList.Select(double.Parse);
        }
    }
}

/// <summary>
/// Linq拡張
/// </summary>
public static class LinqExtension
{
    /// <summary>
    /// 二分探索
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="self"></param>
    /// <param name="solve"></param>
    /// <param name="min"></param>
    /// <param name="max"></param>
    /// <returns></returns>
    public static T LeftBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min, T max)
    {
        int index = self.LeftBinarySearchIndex(solve);

        return self.Get(index, min, max);
    }

    /// <summary>
    /// 二分探索
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="self"></param>
    /// <param name="solve"></param>
    /// <param name="min"></param>
    /// <param name="max"></param>
    /// <returns></returns>
    public static T RightBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min, T max)
    {
        int index = self.RightBinarySearchIndex(solve);

        return self.Get(index, min, max);
    }

    /// <summary>
    /// OutOfRange対応
    /// </summary>
    /// <typeparam name="T">型T</typeparam>
    /// <param name="self">IEnumerable</param>
    /// <param name="index">対象のインデックス</param>
    /// <param name="min">0未満のインデックスの時</param>
    /// <param name="max">配列のサイズ以上の時</param>
    /// <returns>型Tの値</returns>
    public static T Get<T>(this IEnumerable<T> self, int index, T min, T max)
    {
        if (index < 0) return min;
        if (index >= self.Count()) return max;

        return self.ElementAt(index);
    }

    /// <summary>
    /// <para>二分探索</para>
    /// <para>渡されたラムダ式の条件を満たすものの中で、一番左側のもの(インデックスが小さい)</para>
    /// </summary>
    /// <typeparam name="T">IEnumerable</typeparam>
    /// <param name="solve"></param>
    /// <returns>一番左側のインデックス</returns>
    public static int LeftBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve)
    {
        int ng = -1;
        int ok = self.Count();

        while (Math.Abs(ok - ng) > 1)
        {
            int mid = (ok + ng) / 2;

            if (solve(self.ElementAt(mid)))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }

        return ok;
    }

    /// <summary>
    /// <para>二分探索</para>
    /// <para>渡されたラムダ式の条件を満たすものの中で、一番右側のもの(インデックスが大きい)</para>
    /// </summary>
    /// <typeparam name="T">IEnumerable</typeparam>
    /// <param name="solve"></param>
    /// <returns>一番右側のインデックス</returns>
    public static int RightBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve)
    {
        int ng = self.Count();
        int ok = -1;

        while (Math.Abs(ok - ng) > 1)
        {
            int mid = (ok + ng) / 2;

            if (solve(self.ElementAt(mid)))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }

        return ok;
    }

    /// <summary>
    /// リストを埋める
    /// </summary>
    /// <typeparam name="T">型T</typeparam>
    /// <param name="self">リスト</param>
    /// <param name="func">(index) => T</param>
    /// <returns>リストの参照</returns>
    public static IList<T> Fill<T>(this IList<T> self, Func<int, T> func)
    {
        for (int i = 0; i < self.Count; i++)
        {
            self[i] = func(i);
        }

        return self;
    }

    /// <summary>
    /// リストを埋める
    /// </summary>
    /// <typeparam name="T">型T</typeparam>
    /// <param name="self">リスト</param>
    /// <param name="value">型Tの値</param>
    /// <returns>リストの参照</returns>
    public static IList<T> Fill<T>(this IList<T> self, T value)
    {
        for (int i = 0; i < self.Count; i++)
        {
            self[i] = value;
        }

        return self;
    }
}

/// <summary>
/// Int拡張
/// </summary>
public static class IntExtensiton
{
    /// <summary>
    /// 階上
    /// </summary>
    /// <param name="self"></param>
    /// <returns></returns>
    public static long Factorial(this int self)
    {
        return self * self.Factorial();
    }

    /// <summary>
    /// 階上
    /// </summary>
    /// <param name="self"></param>
    /// <returns></returns>
    public static long Factorial(this int self, int c)
    {
        if (c == 0 || self == 0) return 1L;
        return self * Factorial(self - 1, c - 1);
    }

    public static int BitCount(this int bit, int digit = 32)
    {
        int count = 0;
        for (int i = (digit - 1); i >= 0; i--)
        {
            if (bit.GetBit(i)) count++;
        }
        return count;
    }

    public static bool GetBit(this int bit, int digit)
    {
        int mask = (1 << digit);
        return (bit & mask) == mask;
    }

    public static int SetBit(this int bit, int digit)
    {
        return (bit | (1 << digit));
    }

    public static string BitToString(this int bit, int digit = 32)
    {
        StringBuilder sb = new StringBuilder();

        for (int i = (digit - 1); i >= 0; i--)
        {
            sb.Append(bit.GetBit(i) ? "1" : "0");
        }

        return sb.ToString();
    }

    public static bool IsDivisor(this int self, int target)
    {
        return self % target == 0;
    }
}

/// <summary>
/// Long拡張
/// </summary>
public static class LongExtensition
{
    public static long BitCount(this long bit, int digit = 64)
    {
        long count = 0;
        for (int i = (digit - 1); i >= 0; i--)
        {
            if (bit.GetBit(i)) count++;
        }
        return count;
    }

    public static bool GetBit(this long bit, int digit)
    {
        long mask = (1L << digit);
        return (bit & mask) == mask;
    }

    public static long SetBit(this long bit, int digit)
    {
        return bit | (1L << digit);
    }

    public static string BitToString(this long bit, int digit = 64)
    {
        StringBuilder sb = new StringBuilder();

        for (int i = (digit - 1); i >= 0; i--)
        {
            sb.Append(bit.GetBit(i) ? "1" : "0");
        }

        return sb.ToString();
    }

    public static bool IsDivisor(this long self, int target)
    {
        return self % target == 0;
    }
}

/// <summary>
/// String拡張
/// </summary>
public static class StringExtensiton
{
    public static int Int(this string str)
    {
        return int.Parse(str);
    }

    public static long Long(this string str)
    {
        return long.Parse(str);
    }

    public static double Double(this string str)
    {
        return double.Parse(str);
    }
}

public static class F
{
    public static void ChMax<T>(ref T x, T y) where T : IComparable
    {
        if(x.CompareTo(y) < 0)
        {
            x = y;
        }
    }

    public static void ChMin<T>(ref T x, T y) where T : IComparable
    {
        if (x.CompareTo(y) > 0)
        {
            x = y;
        }
    }

    public static void Swap<T>(ref T x, ref T y)
    {
        T tmp = x;

        x = y;
        y = tmp;
    }

}

public class UnionFind
{
    private List<int> Parent;

    public UnionFind(int vertexCount)
    {
        Parent = Enumerable.Range(0, vertexCount).Select(i => -1).ToList();
    }

    /// <summary>
    /// グループの番号を得る
    /// </summary>
    /// <param name="x"></param>
    /// <returns></returns>
    public int Root(int x)
    {
        if (Parent[x] < 0) return x;

        return Parent[x] = Root(Parent[x]);
    }

    /// <summary>
    /// そのグループの頂点数
    /// </summary>
    /// <param name="x">インデックス</param>
    /// <returns>グループの頂点数</returns>
    public int Size(int x)
    {
        return -Parent[Root(x)];
    }

    /// <summary>
    /// 同じグループにする
    /// </summary>
    /// <param name="x">インデックス</param>
    /// <param name="y">インデックス</param>
    public void Unite(int x, int y)
    {
        int rx = Root(x);
        int ry = Root(y);

        if (rx == ry) return;

        if (Parent[rx] > Parent[ry])
        {
            F.Swap(ref rx, ref ry);
        }

        //  子の数を足す
        Parent[ry] += Parent[rx];

        //  親のインデックスを変更する
        Parent[rx] = ry;
    }

    /// <summary>
    /// 同じグループである
    /// </summary>
    /// <param name="x">インデックス</param>
    /// <param name="y">インデックス</param>
    /// <returns>真偽</returns>
    public bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }
}

Measured memory_bytes: 19912