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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Convert.ToInt32(data[0]);
            k = Convert.ToInt32(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];
            Queue<int> queueForCompute = new Queue<int>();
            SortedDictionary<ulong, int> computers = new SortedDictionary<ulong, int>();

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = Convert.ToUInt64(data[0]);
                m[i] = Convert.ToUInt64(data[1]);
            }

            int compIdx = 0;
            ulong curTime = 1;
            int freeComps = k;

            while (true)
            {
                if (computers.ContainsKey(curTime))
                {
                    freeComps += computers[curTime];
                    computers.Remove(curTime);
                }

                if (compIdx < n && s[compIdx] == curTime)
                {
                    if (freeComps > 0)
                    {
                        var workTime = m[compIdx] + curTime;

                        if (computers.ContainsKey(workTime))
                        {
                            computers[workTime]++;
                        }
                        else
                        {
                            computers.Add(workTime, 1);
                        }

                        freeComps--;
                        m[compIdx] += curTime;
                    }
                    else
                    {
                        queueForCompute.Enqueue(compIdx);
                    }

                    compIdx++;
                }

                if (queueForCompute.Count > 0)
                {
                    int count = Math.Min(queueForCompute.Count, freeComps);

                    for (int i = 0; i < count; i++)
                    {
                        int idx = queueForCompute.Dequeue();

                        var workTime = m[idx] + curTime;

                        if (computers.ContainsKey(workTime))
                        {
                            computers[workTime]++;
                        }
                        else
                        {
                            computers.Add(workTime, 1);
                        }

                        freeComps--;
                        m[idx] += curTime;
                    }
                }

                if (compIdx < n)
                {
                    if (computers.Count > 0)
                    {
                        curTime = Math.Min(s[compIdx], computers.First().Key);
                    }
                    else
                    {
                        curTime = s[compIdx];
                    }
                }
                else
                {
                    if (queueForCompute.Count == 0)
                    {
                        break;
                    }

                    curTime = computers.First().Key;
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(m[i]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class MinHeap
    {
        private readonly ulong[] _items;
        private int _count;

        public MinHeap(int length)
        {
            int n = length == 1 ? 1 : (1 << (int)(Math.Log(length - 1, 2) + 1));
            _items = new ulong[2 * n];
            _count = length;
        }

        private void Swap(int i, int j)
        {
            ulong c = _items[i];
            _items[i] = _items[j];
            _items[j] = c;
        }

        private void SiftDown(int i)
        {
            while (2 * i + 1 <= _count)
            {
                int left = 2 * i + 1;
                int right = 2 * i + 2;
                int j = left;
                if (right < _count && _items[right] < _items[left])
                {
                    j = right;
                }
                if (_items[i] <= _items[j]) break;

                Swap(i, j);

                i = j;
            }
        }

        private void SiftUp(int i)
        {
            while (_items[i] < _items[(i-1) / 2])
            {
                Swap(i, (i - 1) / 2);

                i = (i - 1) / 2;
            }
        }

        public ulong ExtractMin()
        {
            ulong min = _items[0];
            _items[0] = _items[_count - 1];
            _count--;

            SiftDown(0);

            return min;
        }

        public void Insert(ulong key)
        {
            _count++;
            _items[_count - 1] = key;
            SiftUp(_count - 1);
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Int32.Parse(data[0]);
            k = Int32.Parse(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];

            MinHeap heap = new MinHeap(k);

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = Convert.ToUInt64(data[0]);
                m[i] = Convert.ToUInt64(data[1]);
            }

            for (int i = 0; i < n; i++)
            {
                var minComp = heap.ExtractMin();

                m[i] += Math.Max(s[i], minComp);
                heap.Insert(m[i]);
            }

            Console.WriteLine(String.Join(Environment.NewLine, m));
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            //new Solver(new StringReader(Tests.Test2)).Solve();
            //Console.Read();
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class MinHeap
    {
        private readonly ulong[] _items;
        private int _count;

        public MinHeap(int length)
        {
            int n = length == 1 ? 1 : (1 << (int)(Math.Log(length - 1, 2) + 1));
            _items = new ulong[2 * n];
            _count = length;
        }

        private void Swap(int i, int j)
        {
            ulong c = _items[i];
            _items[i] = _items[j];
            _items[j] = c;
        }

        private void SiftDown(int i)
        {
            while (2 * i + 1 <= _count)
            {
                int left = 2 * i + 1;
                int right = 2 * i + 2;
                int j = left;
                if (right < _count && _items[right] < _items[left])
                {
                    j = right;
                }
                if (_items[i] <= _items[j]) break;

                Swap(i, j);

                i = j;
            }
        }

        private void SiftUp(int i)
        {
            while (_items[i] < _items[(i-1) / 2])
            {
                Swap(i, (i - 1) / 2);

                i = (i - 1) / 2;
            }
        }

        public ulong ExtractMin()
        {
            ulong min = _items[0];
            _items[0] = _items[_count - 1];
            _count--;

            SiftDown(0);

            return min;
        }

        public void Insert(ulong key)
        {
            _count++;
            _items[_count - 1] = key;
            SiftUp(_count - 1);
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Int32.Parse(data[0]);
            k = Int32.Parse(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];

            MinHeap heap = new MinHeap(k);

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = Convert.ToUInt64(data[0]);
                m[i] = Convert.ToUInt64(data[1]);
            }

            for (int i = 0; i < n; i++)
            {
                var minComp = heap.ExtractMin();

                m[i] += Math.Max(s[i], minComp);
                heap.Insert(m[i]);
            }

            for (int i = 0; i < n;i++)
            {
                Console.WriteLine(m[i]);
            }
                //Console.WriteLine(String.Join(Environment.NewLine, m));
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            //new Solver(new StringReader(Tests.Test2)).Solve();
            //Console.Read();
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class SegmentTree
    {
        private readonly Tuple<ulong, int>[] _items;

        public Tuple<ulong, int> this[int index]
        {
            get { return _items[index]; }
        }

        public SegmentTree(int length)
        {
            int n = length == 1 ? 1 : (1 << Convert.ToInt32(Math.Log(length - 1, 2) + 1));
            _items = new Tuple<ulong, int>[2 * n];

            for (int i = n; i < 2 * n; i++)
            {
                if (i - n < length)
                {
                    _items[i] = Tuple.Create(0UL, i);
                }
                else
                {
                    _items[i] = Tuple.Create(UInt64.MaxValue, Int32.MaxValue);
                }
            }

            for (int i = n - 1; i > 0; i--)
            {
                _items[i] = _items[2 * i].Item1 < _items[2 * i + 1].Item1
                    ? _items[2 * i] : _items[2 * i + 1];
            }
        }

        public void Update(int i, ulong value)
        {
            _items[i] = Tuple.Create(value, i);

            while ((i >>= 1) != 0)
            {
                _items[i] = _items[2 * i].Item1 < _items[2 * i + 1].Item1
                    ? _items[2 * i] : _items[2 * i + 1];
            }
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Convert.ToInt32(data[0]);
            k = Convert.ToInt32(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = Convert.ToUInt64(data[0]);
                m[i] = Convert.ToUInt64(data[1]);
            }

            SegmentTree tree = new SegmentTree(k);

            for (int i = 0; i < n; i++)
            {
                var minComp = tree[1];

                m[i] += Math.Max(s[i], minComp.Item1);
                tree.Update(minComp.Item2, m[i]);

            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(m[i]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class SegmentTree
    {
        private readonly Tuple<ulong, int>[] _items;

        public Tuple<ulong, int> this[int index]
        {
            get { return _items[index]; }
        }

        public SegmentTree(int length)
        {
            int n = length == 1 ? 1 : (1 << (int)(Math.Log(length - 1, 2) + 1));
            _items = new Tuple<ulong, int>[2 * n];

            for (int i = n; i < 2 * n; i++)
            {
                if (i - n < length)
                {
                    _items[i] = Tuple.Create(0UL, i);
                }
                else
                {
                    _items[i] = Tuple.Create(UInt64.MaxValue, Int32.MaxValue);
                }
            }

            for (int i = n - 1; i > 0; i--)
            {
                _items[i] = _items[2 * i].Item1 < _items[2 * i + 1].Item1
                    ? _items[2 * i] : _items[2 * i + 1];
            }
        }

        public void Update(int i, ulong value)
        {
            _items[i] = Tuple.Create(value, i);

            while ((i >>= 1) != 0)
            {
                _items[i] = _items[2 * i].Item1 < _items[2 * i + 1].Item1
                    ? _items[2 * i] : _items[2 * i + 1];
            }
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Int32.Parse(data[0]);
            k = Int32.Parse(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];

            SegmentTree tree = new SegmentTree(k);

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = UInt64.Parse(data[0]);
                m[i] = UInt64.Parse(data[1]);
                var minComp = tree[1];

                m[i] += Math.Max(s[i], minComp.Item1);
                tree.Update(minComp.Item2, m[i]);

                Console.WriteLine(m[i]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            /*new Solver(new StringReader(Tests.Test1)).Solve();
            Console.Read();*/
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


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

namespace VKCup2_D
{

    public interface IReader
    {
        string GetNextLine();
    }

    public static class Tests
    {
        public static readonly string Test1 =
@"3 2
1 5
2 5
3 5";

        public static readonly string Test2 =
@"6 1
1 1000000000
2 1000000000
3 1000000000
4 1000000000
5 1000000000
6 3";

        public static readonly string Test3 =
@"56 16
4 1798
7 3101
8 2607
10 8984
11 116
13 1758
14 3977
16 3374
18 535
19 5632
20 4016
22 4884
23 5604
25 2734
28 4882
31 7408
33 9041
35 7576
36 800
37 4029
38 8604
39 1477
40 2400
41 8073
42 3282
45 6988
46 972
47 5288
48 8712
51 7385
53 9793
54 6319
55 9254
57 5759
59 305
60 7722
62 2296
63 4048
69 1649
75 6566
77 2571
80 1191
82 5548
83 4135
86 7494
88 1198
90 9550
92 2708
93 2526
96 8712
100 2249
101 9686
102 8768
103 6776
105 996
108 1133";
    }

    public class StringReader : IReader
    {
        private readonly string[] _text;
        private int index = 0;

        public StringReader(string text)
        {
            _text = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
        }

        public string GetNextLine()
        {
            return _text[index++];
        }
    }

    public class ConsoleReader : IReader
    {
        public string GetNextLine()
        {
            return Console.ReadLine();
        }
    }

    public class Solver
    {
        private readonly IReader _reader;

        public Solver(IReader reader)
        {
            _reader = reader;
        }

        public void Solve()
        {
            string[] data = _reader.GetNextLine().Split(' ');
            int n, k;
            n = Convert.ToInt32(data[0]);
            k = Convert.ToInt32(data[1]);

            ulong[] s, m;

            s = new ulong[n];
            m = new ulong[n];
            Queue<int> queueForCompute = new Queue<int>();
            SortedDictionary<ulong, int> computers = new SortedDictionary<ulong, int>();

            for (int i = 0; i < n; i++)
            {
                data = _reader.GetNextLine().Split(' ');
                s[i] = Convert.ToUInt64(data[0]);
                m[i] = Convert.ToUInt64(data[1]);
            }

            int compIdx = 0;
            ulong curTime = 1;
            int freeComps = k;

            while (true)
            {
                if (computers.ContainsKey(curTime))
                {
                    freeComps += computers[curTime];
                    computers.Remove(curTime);
                }

                if (queueForCompute.Count > 0)
                {
                    int count = Math.Min(queueForCompute.Count, freeComps);

                    for (int i = 0; i < count; i++)
                    {
                        int idx = queueForCompute.Dequeue();

                        var workTime = m[idx] + curTime;

                        if (computers.ContainsKey(workTime))
                        {
                            computers[workTime]++;
                        }
                        else
                        {
                            computers.Add(workTime, 1);
                        }

                        freeComps--;
                        m[idx] += curTime;
                    }
                }

                if (compIdx < n && s[compIdx] == curTime)
                {
                    if (freeComps > 0)
                    {
                        var workTime = m[compIdx] + curTime;

                        if (computers.ContainsKey(workTime))
                        {
                            computers[workTime]++;
                        }
                        else
                        {
                            computers.Add(workTime, 1);
                        }

                        freeComps--;
                        m[compIdx] += curTime;
                    }
                    else
                    {
                        queueForCompute.Enqueue(compIdx);
                    }

                    compIdx++;
                }

                if (compIdx < n)
                {
                    if (computers.Count > 0)
                    {
                        curTime = Math.Min(s[compIdx], computers.First().Key);
                    }
                    else
                    {
                        curTime = s[compIdx];
                    }
                }
                else
                {
                    if (queueForCompute.Count == 0)
                    {
                        break;
                    }

                    curTime = computers.First().Key;
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(m[i]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new Solver(new ConsoleReader()).Solve();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }

    public void Solve()
    {
        var n = ReadInt();
        var k = ReadInt();

        var list = new SortedSet<Tuple<long, int>>(new Comparer());
        for (var i = 0; i < k; i++)
        {
            list.Add(Tuple.Create(0L, i));
        }
        for (var i = 0; i < n; i++)
        {
            var s = ReadInt();
            var m = ReadInt();

            var min = list.Min;
            var newM = Math.Max(s, min.Item1) + m;
            list.Remove(min);
            Console.WriteLine(newM);
            list.Add(Tuple.Create(newM, min.Item2));

        }
    }

    #region Main

    protected static TextReader Reader;
    protected static TextWriter Writer;

    static void Main()
    {
#if DEBUG
        Reader = new StreamReader(@"C:\temp\input.txt");
        Writer = Console.Out;
        //        Writer = new StreamWriter(@"C:\temp\output.txt");
#else
        Reader = new StreamReader(Console.OpenStandardInput());
        Writer = new StreamWriter(Console.OpenStandardOutput());
        //Reader = new StreamReader("cycle.in");
        //Writer = new StreamWriter("cycle.out");
#endif
        try
        {
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        Reader.Close();
        Writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> _currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (_currentLineTokens.Count == 0)
            _currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return _currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = Reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        Writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            Writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();

        var q = new SortedSet<Tuple<long, int>>(new Comparer());
        for (int i = 0; i < m; i++)
            q.Add(Tuple.Create(0L, i));

        for (; n > 0; n--)
        {
            int l = ReadInt();
            int d = ReadInt();
            var min = q.Min;
            q.Remove(min);
            long v = Math.Max(min.Item1, l) + d;
            Write(v);
            q.Add(Tuple.Create(v, min.Item2));
        }
    }

    #region Main

    protected static TextReader Reader;
    protected static TextWriter Writer;

    static void Main()
    {
#if DEBUG
        Reader = new StreamReader(@"C:\temp\input.txt");
        Writer = Console.Out;
//        Writer = new StreamWriter(@"C:\temp\output.txt");
#else
        Reader = new StreamReader(Console.OpenStandardInput());
        Writer = new StreamWriter(Console.OpenStandardOutput());
        //Reader = new StreamReader("cycle.in");
        //Writer = new StreamWriter("cycle.out");
#endif
        try
        {
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        Reader.Close();
        Writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> _currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (_currentLineTokens.Count == 0)
            _currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return _currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = Reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        Writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            Writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];

        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            int min = 0;
            bool b = false;
            ulong newM;
            if (list[min] < s)
            {
                newM = (ulong)m + s;
                list[min] = newM;
                b = true;
                Console.WriteLine(newM);

            }
            if (!b)
                for (int j = 1; j < k; j++)
                {
                    if (list[j] < s)
                    {
                        newM = (ulong)m + s;
                        list[j] = newM;
                        b = true;
                        Console.WriteLine(newM);
                        break;
                    }
                    if (list[j] < list[min])
                    {
                        min = j;
                    }
                }

            if (!b)
            {
                newM = (ulong)m + list[min];
                list[min] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Linq;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            long min = 0;
            ulong newM;

//            long j = Z;
            var minI = list.Min();
            var j = Array.IndexOf(list, minI);
//            while (list[j] > s && count < k )
//            {
//                if (list[j] < list[min])
//                {
//                    min = j;
//                }
//                j++;
//                j %= k;
//                count++;
//            }
//            Z = j;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[j];
                list[j] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Linq;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            long min = 0;
            ulong newM;

//            long j = Z;
            var minI = list.Min();
            var j = Array.IndexOf(list, minI);
//            while (list[j] > s && count < k )
//            {
//                if (list[j] < list[min])
//                {
//                    min = j;
//                }
//                j++;
//                j %= k;
//                count++;
//            }
//            Z = j;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[min];
                list[j] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];

        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            int min = 0;
            for (int j = 1; j < k; j++)
            {
                if (list[j] < list[min])
                {
                    min = j;
                }
            }

            ulong newM = list[min] + (ulong)m + (list[min] > s ? 0: s);
            list[min] = newM;
            Console.WriteLine(newM);
        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Integer();

        var list = new SortedSet<Tuple<long, int>>(new Comparer());
        for (var i = 0; i < k; i++)
        {
            list.Add(Tuple.Create(0L, i));
        }
        for (var i = 0; i < n; i++)
        {
            var s = _scanner.Long();
            var m = _scanner.Long();

            var min = list.Min;
            var newM = Math.Max(m + s, m + min.Item1);
            list.Remove(min);
            list.Add(Tuple.Create(newM, min.Item2));
            Console.WriteLine(newM);

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];
        long Z = 0;
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            long min = 0;
            ulong newM;

            long j = Z;
            var count = 0;
            while (list[j] > s && count < k )
            {
                if (list[j] < list[min])
                {
                    min = j;
                }
                j++;
                j %= k;
                count++;
            }
            Z = j;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[min];
                list[min] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];

        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            int min = 0;
            for (int j = 1; j < k; j++)
            {
                if (list[j] < list[min])
                {
                    min = j;
                }
            }

            ulong newM = (ulong)m + (list[min] > s ?  list[min]: s);
            list[min] = newM;
            Console.WriteLine(newM);
        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Linq;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            long min = 0;
            ulong newM;

//            long j = Z;
            var minI = list.Min();
            var j = Array.IndexOf(list, minI);
//            while (list[j] > s && count < k )
//            {
//                if (list[j] < list[min])
//                {
//                    min = j;
//                }
//                j++;
//                j %= k;
//                count++;
//            }
//            Z = j;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[min];
                list[min] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }

    public void Solve()
    {
        var n = ReadInt();
        var k = ReadInt();

        var list = new SortedSet<Tuple<long, int>>(new Comparer());
        for (var i = 0; i < k; i++)
        {
            list.Add(Tuple.Create(0L, i));
        }
        for (; n>0; n--)
        {
            var s = ReadInt();
            var m = ReadInt();

            var min = list.Min;
            var newM = Math.Max(s, min.Item1) + m;
            list.Remove(min);
            Write(newM);
            list.Add(Tuple.Create(newM, min.Item2));

        }
    }

    #region Main

    protected static TextReader Reader;
    protected static TextWriter Writer;

    static void Main()
    {
#if DEBUG
        Reader = new StreamReader(@"C:\temp\input.txt");
        Writer = Console.Out;
        //        Writer = new StreamWriter(@"C:\temp\output.txt");
#else
        Reader = new StreamReader(Console.OpenStandardInput());
        Writer = new StreamWriter(Console.OpenStandardOutput());
        //Reader = new StreamReader("cycle.in");
        //Writer = new StreamWriter("cycle.out");
#endif
        try
        {
            new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        Reader.Close();
        Writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> _currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return Reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (_currentLineTokens.Count == 0)
            _currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return _currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = Reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        Writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            Writer.WriteLine(a);
    }

    class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }

    #endregion
}


using System;
using System.Collections.Generic;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new List<ulong>();
        for (int i = 0; i < k; i++)
        {
            list.Add(0);
        }
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            ulong newM;
            var j = 0;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[j];
                list[j] = newM;
                Console.WriteLine(newM);
            }

            var value = list[0];
            var bx = true;
            for (int l = 1; l < k; l++)
            {
                if (list[l] < value)
                {
                    list.Insert(l+1, value);
                    list.RemoveAt(0);
                    bx = false;
                    break;
                }
            }
            if (bx)
            {
                list.Insert(list.Count-1, value);
                list.RemoveAt(0);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;

public class Solver
{
     class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Integer();

        var list = new SortedSet<Tuple<long, int>>(new Comparer());
        for (int i = 0; i < k; i++)
        {
            list.Add(Tuple.Create(0L, i));
        }
        for (var i = 0; i < n; i++)
        {
            var s = _scanner.Long();
            var m = _scanner.Long();

            long newM;
            var min = list.Min;

            if (min.Item1 <= s)
            {
                newM = m + s;
                list.Remove(min);
                list.Add(Tuple.Create(newM, min.Item2));
                Console.WriteLine(newM);
            }
            else
            {
                newM = m + min.Item1;
                list.Remove(min);
                list.Add(Tuple.Create(newM, min.Item2));
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Linq;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Long();

        var list = new ulong[k];
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            ulong newM;

//            long j = Z;
           Array.Sort(list);
            var j = 0;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }else
            {
                newM = (ulong)m + list[j];
                list[j] = newM;
                Console.WriteLine(newM);
            }

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }
    void Solve()
    {
        int n = _scanner.Integer();
        int m = _scanner.Integer();

        var q = new SortedSet<Tuple<long, int>>(new Comparer());
        for (int i = 0; i < m; i++)
            q.Add(Tuple.Create(0L, i));

        for (; n > 0; n--)
        {
            int l = _scanner.Integer();
            int d = _scanner.Integer();
            var min = q.Min;
            q.Remove(min);
            long v = Math.Max(min.Item1, l) + d;
            Console.WriteLine(v);
            q.Add(Tuple.Create(v, min.Item2));
        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;

public class Solver
{
    class Comparer : IComparer<Tuple<long, int>>
    {
        public int Compare(Tuple<long, int> x, Tuple<long, int> y)
        {
            return x.Item1 == y.Item1 ? x.Item2 - y.Item2 : x.Item1.CompareTo(y.Item1);
        }
    }
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Integer();

        var list = new SortedSet<Tuple<long, int>>(new Comparer());
        for (var i = 0; i < k; i++)
        {
            list.Add(Tuple.Create(0L, i));
        }
        for (var i = 0; i < n; i++)
        {
            var s = _scanner.Long();
            var m = _scanner.Long();

            var min = list.Min;
            var newM = Math.Max(s,min.Item1)+m;
            list.Remove(min);
            Console.WriteLine(newM);
            list.Add(Tuple.Create(newM, min.Item2));

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


using System;
using System.Collections.Generic;

public class Solver
{
    void Solve()
    {
        var n = _scanner.Long();
        var k = _scanner.Integer();

        var list = new List<ulong>();
        for (int i = 0; i < k; i++)
        {
            list.Add(0);
        }
        for (int i = 0; i < n; i++)
        {
            ulong s = (ulong)_scanner.Long();
            var m = _scanner.Long();

            ulong newM;
            var j = 0;

            if (list[j] <= s)
            {
                newM = (ulong)m + s;
                list[j] = newM;
                Console.WriteLine(newM);
            }
            else
            {
                newM = (ulong)m + list[j];
                list[j] = newM;
                Console.WriteLine(newM);
            }

            var value = list[0];

            var l = k - 1;
            while (list[l] > value && l > 0)
            {
                l--;
            }

            list.Insert(l+1, value);
            list.RemoveAt(0);

        }
    }

    static void Main()
    {
#if DEBUG
        var iStream = new System.IO.FileStream(@"C:\temp\input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
            Console.ReadKey(true);
        }
#endif
    }

    readonly Scanner _scanner = new Scanner();
}

public class Scanner
{
    readonly private System.Globalization.CultureInfo _info;
    readonly System.IO.TextReader _reader;
    string[] _buffer = new string[0];
    int _position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        _reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        Separator = separator.ToCharArray();
        _info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (_position < _buffer.Length)
            return _buffer[_position++];
        do _buffer = _reader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
        while (_buffer.Length == 0);
        _position = 0;
        return _buffer[_position++];
    }

    public string ScanLine()
    {
        if (_position >= _buffer.Length)
            return _reader.ReadLine();

        var sb = new System.Text.StringBuilder();
        for (; _position < _buffer.Length; _position++)
        {
            sb.Append(_buffer[_position]);
            sb.Append(' ');
        }
        return sb.ToString();
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
            ar[i] = Scan();
        return ar;
    }

    public int Integer()
    {
        return int.Parse(Scan(), _info);
    }
    public long Long()
    {
        return long.Parse(Scan(), _info);
    }
    public double Double()
    {
        return double.Parse(Scan(), _info);
    }
    public double Double(string str)
    {
        return double.Parse(str, _info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = Double();
        return a;
    }

}


import java.util.*

/**
 * Created by yaroslav.ovcharenko on 12/2/16.
 */
fun main(args: Array<String>) {
    val c = Comparator<Long> { l, r ->
        if(l<r) {
            -1
        }
        else {
            1
        }
    }
    val tree = sortedSetOf(c)
    val vs = readInts()
    for (i in 0..vs[0]-1) {
        val video = readInts()
        println(getVTime(vs[1], video, tree))
    }
}

fun getVTime(servers:Int, video: List<Int>, tree: SortedSet<Long>): Long {
    val t = video[0]
    val len = video[1]
    if(tree.size < servers) {
        val total:Long = (t + len).toLong()
        tree.add(total)
        return total
    } else {
        var toAdd = 0L
        val min = tree.first()
        if (min > t) {
            toAdd  = min + len
        } else {
            toAdd = (t + len).toLong()
        }
        val iterator = tree.iterator()
        iterator.next()
        iterator.remove()
        tree.add(toAdd)
        return toAdd
    }
}

private fun readInts() = readLine()!!.split(" ").map(String::toInt)


import java.io.BufferedOutputStream
import java.io.BufferedWriter
import java.nio.charset.StandardCharsets
import java.util.*

/**
 * Created by yaroslav.ovcharenko on 12/2/16.
 */
fun main(args: Array<String>) {
    val wr = BufferedOutputStream(System.out)

    val tree = PriorityQueue<Long>()
    val vs = readInts()
    val toByteArray = "\n".toByteArray(StandardCharsets.UTF_8)
    for (i in 0..vs[0]-1) {
        val video = readInts()
        wr.write(getVTime(vs[1], video, tree).toString().toByteArray(StandardCharsets.UTF_8))
        wr.write(toByteArray)
    }
    wr.flush()
    wr.close()
}

fun getVTime(servers:Int, video: List<Int>, tree: PriorityQueue<Long>): Long {
    val t = video[0]
    val len = video[1]
    if(tree.size < servers) {
        val total:Long = (t + len).toLong()
        tree.add(total)
        return total
    } else {
        var toAdd = 0L
        val min = tree.poll()
        if (min > t) {
            toAdd  = min + len
        } else {
            toAdd = (t + len).toLong()
        }
        tree.add(toAdd)
        return toAdd
    }
}

private fun readInts() = readLine()!!.split(" ").map(String::toInt)


import java.io.BufferedOutputStream
import java.io.BufferedWriter
import java.nio.charset.StandardCharsets
import java.util.*

/**
 * Created by yaroslav.ovcharenko on 12/2/16.
 */
fun main(args: Array<String>) {
    val wr = BufferedOutputStream(System.out)
    val c = Comparator<Long> { l, r ->
        if(l<r) {
            -1
        }
        else {
            1
        }
    }
    val tree = sortedSetOf(c)
    val vs = readInts()
    for (i in 0..vs[0]-1) {
        val video = readInts()
        wr.write(getVTime(vs[1], video, tree).toString().toByteArray(StandardCharsets.UTF_8))
        wr.write("\n".toByteArray(StandardCharsets.UTF_8))
//        println(getVTime(vs[1], video, tree))
    }
    wr.flush()
    wr.close()
}

fun getVTime(servers:Int, video: List<Int>, tree: SortedSet<Long>): Long {
    val t = video[0]
    val len = video[1]
    if(tree.size < servers) {
        val total:Long = (t + len).toLong()
        tree.add(total)
        return total
    } else {
        var toAdd = 0L
        val min = tree.first()
        if (min > t) {
            toAdd  = min + len
        } else {
            toAdd = (t + len).toLong()
        }
        val iterator = tree.iterator()
        iterator.next()
        iterator.remove()
        tree.add(toAdd)
        return toAdd
    }
}

private fun readInts() = readLine()!!.split(" ").map(String::toInt)


import java.io.BufferedOutputStream
import java.io.BufferedWriter
import java.nio.charset.StandardCharsets
import java.util.*

/**
 * Created by yaroslav.ovcharenko on 12/2/16.
 */
fun main(args: Array<String>) {
    val wr = BufferedOutputStream(System.out)

    val tree = PriorityQueue<Long>()
    val vs = readInts();
    val toByteArray = "\n".toByteArray(StandardCharsets.UTF_8)
    for (i in 0..vs[0]-1) {
        val video = readInts()
        wr.write(getVTime(vs[1], video, tree).toString().toByteArray(StandardCharsets.UTF_8))
        wr.write(toByteArray)
    }
    wr.flush()
    wr.close()
}

fun getVTime(servers:Int, video: List<Int>, tree: PriorityQueue<Long>): Long {
    val t = video[0]
    val len = video[1]
    if(tree.size < servers) {
        val total:Long = (t + len).toLong()
        tree.add(total)
        return total
    } else {
        var toAdd = 0L
        val min = tree.poll()
        if (min > t) {
            toAdd  = min + len
        } else {
            toAdd = (t + len).toLong()
        }
        tree.add(toAdd)
        return toAdd
    }
}

private fun readInts() = readLine()!!.split(" ").map(String::toInt)


#include <bits/stdc++.h>

using namespace std;

struct aaa
{
    long long s, m, id;
};

int n, k;
aaa m[1000000];
long long ans[1000000];
set <long long> s;

bool cmp(aaa a, aaa b)
{
    return (a.s < b.s || a.s == b.s && a.id < b.id);
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> m[i].s >> m[i].m;
        m[i].id = i;
    }
    sort(m, m + n, cmp);
    for (int i = 0; i < n; ++i)
        if (s.size() < k)
        {
            ans[m[i].id] = m[i].s + m[i].m;
            s.insert(m[i].s + m[i].m);
        }
        else
        {
            set <long long> :: iterator ss = s.begin();
            long long t = *ss;
            t = max(t, (long long) m[i].s);
            s.erase(ss);
            ans[m[i].id] = t + m[i].m;
            s.insert(t+m[i].m);

        }
    for (int i = 0; i < n; ++i)
        cout << ans[i] << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct aaa
{
    int s, m, id;
};

int n, k;
aaa m[1000000];
long long ans[1000000];
set <long long> s;

bool cmp(aaa a, aaa b)
{
    return (a.s < b.s || a.s == b.s && a.id < b.id);
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> m[i].s >> m[i].m;
        m[i].id = i;
    }
    for (int i = 0; i < n; ++i)
        if (s.size() < k)
        {
            ans[m[i].id] = m[i].s + m[i].m;
            s.insert(m[i].s + m[i].m);
        }
        else
        {
            set <long long> :: iterator ss = s.begin();
            long long t = *ss;
            t = max(t, (long long) m[i].s);
            s.erase(ss);
            ans[m[i].id] = t + m[i].m;
            s.insert(t+m[i].m);

        }
    for (int i = 0; i < n; ++i)
        cout << ans[i] << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct aaa
{
    int s, m, id;
};

int n, k;
aaa m[1000000];
long long ans[1000000];
multiset <long long> s;

bool cmp(aaa a, aaa b)
{
    return (a.s < b.s || a.s == b.s && a.id < b.id);
}

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> m[i].s >> m[i].m;
        m[i].id = i;
    }
    for (int i = 0; i < n; ++i)
        if (s.size() < k)
        {
            ans[m[i].id] = m[i].s + m[i].m;
            s.insert(m[i].s + m[i].m);
        }
        else
        {
            set <long long> :: iterator ss = s.begin();
            long long t = *ss;
            t = max(t, (long long) m[i].s);
            s.erase(ss);
            ans[m[i].id] = t + m[i].m;
            s.insert(t+m[i].m);

        }
    for (int i = 0; i < n; ++i)
        cout << ans[i] << '\n';
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <memory>

using namespace std;

int main()
{
    int videoCount, serverCount;
    cin >> videoCount >> serverCount;

    unique_ptr<vector<uint32_t>> servers(new vector<uint32_t>(serverCount));
    unique_ptr<vector<uint32_t>> results(new vector<uint32_t>(videoCount));

    int t, duration;
    for (int i = 0; i < videoCount; i++)
    {
        cin >> t >> duration;

        auto min = min_element(servers->begin(), servers->end());
        if (t > *min)
            *min = t;

        *min += duration;
        (*results)[i] = *min;
    }

    for (const uint32_t& i : *results)
    {
        cout << i << endl;
    }

    getchar();
    return 0;
}