Problem:
Max Score: $1200$ Points

Problem statement

There are $N$ customers in a restaurant. Each customer is numbered $1$ through $N$.

A sushi chef carried out $Q$ operations for customers.

The $i$-th operation is follows:

The sushi chef chooses a customer whose number of dishes of sushi eaten is minimum, in customer $1, 2, 3, \dots, a_i$. If there are multiple customers who are minimum numbers of dishes, he selects the minimum-numbered customers.

He puts a dish of sushi on the selected seats.

A customer who have selected for professional eats this sushi.

Repeat 1-3, $b_i$ times.

Please calculate the number of dishes of sushi that have been eaten by each customer.

Input

The input is given from Standard Input in the following format:

$N \ Q$
$a_1 \ b_1$
$a_2 \ b_2$
$ ： \ ： $
$a_Q \ b_Q$

Output

You have to print $N$ lines.

The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$.

Constraints

$3 \le N, Q \le 100,000$

$1 \le a_i \le N$

$1 \le b_i \le 10^{12}$

Any final results do not exceed $2 \times 10^{13}$.

Subtasks

Subtask 1 [ $60$ points ]

$N, Q \le 100$

$b_i = 1$

Subtask 2 [ $400$ points ]

$N, Q \le 100$

$b_i \le 10^{12}$

Subtask 3 [ $240$ points ]

$N, Q \le 100,000$

$b_i = 1$

Subtask 4 [ $500$ points ]

There are no additional constraints.

Sample Input 1

9 3
5 11
8 4
4 7

Sample Output 1

4
4
4
4
2
2
1
1
0

The change of the number of dishes of sushi have eaten is following:

Customer 1

Customer 2

Customer 3

Customer 4

Customer 5

Customer 6

Customer 7

Customer 8

Customer 9

1st Operation

3

2

2

2

2

0

0

0

0

2nd Operation

3

2

2

2

2

2

1

1

0

3rd Operation

4

4

4

4

2

2

1

1

0

Sample Input 2

6 6
3 5
6 11
1 6
4 7
5 2
2 5

Sample Output 2

10
10
5
5
4
2

Sample Input 3

5 6
1 1
2 1
3 1
1 1
5 1
3 1

Sample Output 3

2
2
1
1
0

Sample Input 4

10 10
10 10
9 20
8 30
7 40
6 50
5 60
4 70
3 80
2 90
1 100

Sample Output 4

223
123
77
50
33
21
12
7
3
1

Writer: E869120

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using Number = System.Int64;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var q = sc.Integer();
            var seg = new LazyEvaluateSetSumTree(n);
            for (int i = 0; i < q; i++)
            {
                var k = sc.Integer();
                var v = sc.Long();
                var l = -1; var r = k - 1;
                while (l + 1 < r)
                {
                    var m = (l + r) / 2;
                    var val = seg.Query(m, m + 1);
                    var len = k - m;
                    var sum = seg.Query(m, k);
                    if (len * val - sum <= v) r = m;
                    else l = m;
                }
                {
                    var val = seg.Query(r, r + 1);
                    var len = k - r;
                    var sum = seg.Query(r, k);
                    seg.Set(r, k, val);
                    v -= len * val - sum;
                }
                {
                    var len = k - r;
                    var val = seg.Query(r, r + 1);
                    val += v / len;
                    seg.Set(r, k, val);
                    v %= len;
                    int nr = (int)(r + v);
                    if (v > 0)
                        seg.Set(r, nr, val + 1);
                }
                /*
                var hoge = new List<long>();
                for (int j = 0; j < n; j++) hoge.Add(seg.Query(j, j + 1));
                Debug.WriteLine(hoge.AsJoinedString());
                */
            }
            for (int i = 0; i < n; i++)
                IO.Printer.Out.WriteLine(seg.Query(i, i + 1));
        }

        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}
#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion
#region LazyEvalSetSum
public class LazyEvaluateSetSumTree
{
    int n;
    long[] data;
    long[] lazy;
    public LazyEvaluateSetSumTree(int size)
    {
        n = 1;
        while (n < size)
            n <<= 1;
        data = new long[n << 1];
        lazy = new long[n << 1];
        for (int i = 0; i < lazy.Length; i++)
            lazy[i] = -1;
    }
    private void lazyEval(int k, int a, int b)
    {
        if (lazy[k] == -1)
            return;
        Update(a, (a + b) >> 1, lazy[k], k << 1, a, (a + b) >> 1);
        Update((a + b) >> 1, b, lazy[k], (k << 1) + 1, (a + b) >> 1, b);
        lazy[k] = -1;
    }
    private void eval(int k)
    {
        int l = k << 1, r = (k << 1) + 1;
        data[k] = data[l] + data[r];
    }
    public void Set(int a, int b, long v)
    {
        Update(a, b, v, 1, 0, n);
    }
    private void Update(int a, int b, long v, int k, int l, int r)
    {
        if (r <= a || b <= l)
            return;
        else if (a <= l && r <= b)
        {
            lazy[k] = v;
            data[k] = v * (r - l);
        }
        else
        {
            lazyEval(k, l, r);
            Update(a, b, v, k << 1, l, (l + r) >> 1);
            Update(a, b, v, (k << 1) + 1, (l + r) >> 1, r);
            eval(k);
        }
    }
    public long Query(int a, int b) { return Query(a, b, 1, 0, n); }
    private long Query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
            return 0;
        if (a <= l && r <= b)
            return data[k];
        else
        {
            lazyEval(k, l, r);
            var vl = Query(a, b, k << 1, l, (l + r) >> 1);
            var vr = Query(a, b, (k << 1) + 1, (l + r) >> 1, r);
            eval(k);
            return vl + vr;
        }
    }

}
#endregion