There is a bus stop near the university. The lessons are over, and n students come to the stop. The i-th student will appear at the bus stop at time ti (all ti's are distinct).

We shall assume that the stop is located on the coordinate axis Ox, at point x = 0, and the bus goes along the ray Ox, that is, towards the positive direction of the coordinate axis, and back. The i-th student needs to get to the point with coordinate xi (xi > 0).

The bus moves by the following algorithm. Initially it is at point 0. The students consistently come to the stop and get on it. The bus has a seating capacity which is equal to m passengers. At the moment when m students get on the bus, it starts moving in the positive direction of the coordinate axis. Also it starts moving when the last (n-th) student gets on the bus. The bus is moving at a speed of 1 unit of distance per 1 unit of time, i.e. it covers distance y in time y.

Every time the bus passes the point at which at least one student needs to get off, it stops and these students get off the bus. The students need 1 + [k / 2] units of time to get off the bus, where k is the number of students who leave at this point. Expression [k / 2] denotes rounded down k / 2. As soon as the last student leaves the bus, the bus turns around and goes back to the point x = 0. It doesn't make any stops until it reaches the point. At the given point the bus fills with students once more, and everything is repeated.

If students come to the stop when there's no bus, they form a line (queue) and get on the bus in the order in which they came. Any number of students get on the bus in negligible time, you should assume that it doesn't take any time. Any other actions also take no time. The bus has no other passengers apart from the students.

Write a program that will determine for each student the time when he got off the bus. The moment a student got off the bus is the moment the bus stopped at the student's destination stop (despite the fact that the group of students need some time to get off).

Input

The first line contains two space-separated integers n, m (1 ≤ n, m ≤ 105) — the number of students and the number of passengers the bus can transport, correspondingly. Next n lines contain descriptions of the students, one per line. Each line contains a pair of integers ti, xi (1 ≤ ti ≤ 105, 1 ≤ xi ≤ 104). The lines are given in the order of strict increasing of ti. Values of xi can coincide.

Output

Print n numbers w1, w2, ..., wn, wi — the moment of time when the i-th student got off the bus. Print the numbers on one line and separate them with single spaces.

Examples

Input

1 10
3 5


Output

8


Input

2 1
3 5
4 5


Output

8 19


Input

5 4
3 5
4 5
5 5
6 5
7 1


Output

11 11 11 11 20


Input

20 4
28 13
31 13
35 6
36 4
52 6
53 4
83 2
84 4
87 1
93 6
108 4
113 6
116 1
125 2
130 2
136 13
162 2
166 4
184 1
192 2


Output

51 51 43 40 93 89 86 89 114 121 118 121 137 139 139 152 195 199 193 195

Note

In the first sample the bus waits for the first student for 3 units of time and drives him to his destination in additional 5 units of time. So the student leaves the bus at the moment of time 3 + 5 = 8.

In the second sample the capacity of the bus equals 1, that's why it will drive the first student alone. This student is the same as the student from the first sample. So the bus arrives to his destination at the moment of time 8, spends 1 + [1 / 2] = 1 units of time on getting him off, and returns back to 0 in additional 5 units of time. That is, the bus returns to the bus stop at the moment of time 14. By this moment the second student has already came to the bus stop. So he immediately gets in the bus, and is driven to his destination in additional 5 units of time. He gets there at the moment 14 + 5 = 19. 

In the third sample the bus waits for the fourth student for 6 units of time, then drives for 5 units of time, then gets the passengers off for 1 + [4 / 2] = 3 units of time, then returns for 5 units of time, and then drives the fifth student for 1 unit of time.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;

public class Bus {
    public static void main(String[] args) {
        solve();
    }

    public static void solve() {
        BufferedReader br = null;
        InputStreamReader is = null;
        is = new InputStreamReader(System.in);
        br = new BufferedReader(is);
        try {
            String[] firstStr = br.readLine().split(" ");
            final int studentsNumber = Integer.valueOf(firstStr[0]);
            final int busCapacity = Integer.valueOf(firstStr[1]);
            PriorityQueue<Student> station = new PriorityQueue<Student>(studentsNumber,
                    new Comparator<Student>() {
                        @Override
                        public int compare(Student s1, Student s2) {
                            if (s1.getCameTime() < s2.getCameTime())
                                return -1;
                            if (s1.getCameTime() == s2.getCameTime())
                                return 0;
                            return 1;
                        }
                    });
            for (int studentId = 0; studentId < studentsNumber; ++studentId) {
                String[] studentParms = br.readLine().split(" ");
                int cameTime = Integer.valueOf(studentParms[0]);
                int destination = Integer.valueOf(studentParms[1]);
                station.add(new Student(studentId, cameTime, destination));
            }
            int currentTime = 0;
            int currentPosition = 0;
            PriorityQueue<Student> bus = new PriorityQueue<Student>(
                    studentsNumber, new Comparator<Student>() {
                        @Override
                        public int compare(Student s1, Student s2) {
                            if (s1.getDestination() < s2.getDestination())
                                return -1;
                            if (s1.getDestination() == s2.getDestination())
                                return 0;
                            return 1;
                        }
                    });
            PriorityQueue<Student> arrived = new PriorityQueue<Student>(studentsNumber, 
                    new Comparator<Student>() {
                        @Override
                        public int compare(Student s1, Student s2) {
                            if (s1.getId() < s2.getId())
                                return -1;
                            if (s1.getId() == s2.getId())
                                return 0;
                            return 1;
                        }
                
            });
            int lastPosition = 0;
            while (arrived.size() < studentsNumber) {
                while (bus.size() < busCapacity && station.size() > 0) {
                    Student student = station.poll();
                    if (student.getCameTime() > currentTime)
                        currentTime = student.getCameTime();
                    bus.add(student);
                }
                while (bus.size() > 0) {
                    lastPosition = currentPosition;
                    currentPosition = bus.peek().getDestination();
                    currentTime += currentPosition - lastPosition;
                    int arrivedSt = 0;
                    while (bus.size() > 0 && bus.peek().getDestination() == currentPosition) {
                        Student student = bus.poll();
                        student.setArrivalTime(currentTime);
                        arrived.add(student);
                        ++arrivedSt;
                    }
                    if (arrivedSt > 0)
                        currentTime += 1 + arrivedSt / 2;
                }
                currentTime += currentPosition;
                currentPosition = 0;
            }
            StringBuffer res = new StringBuffer();
            while (arrived.size() > 1) {
                res.append(arrived.poll().getArrivalTime());
                res.append(" ");
            }
            res.append(arrived.peek().getArrivalTime());
            System.out.println(res);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (is != null)
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            if (br != null)
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
        }

    }

}

class Student {
    private int id;
    private int cameTime;
    private int arrivalTime;
    private int destination;

    public Student(int id, int cameTime, int destination) {
        this.id = id;
        this.cameTime = cameTime;
        this.destination = destination;
    }

    public int getId() {
        return id;
    }

    public int getArrivalTime() {
        return arrivalTime;
    }

    public int getDestination() {
        return destination;
    }

    public int getCameTime() {
        return cameTime;
    }

    public void setCameTime(int cameTime) {
        this.cameTime = cameTime;
    }

    public void setArrivalTime(int arrivalTime) {
        this.arrivalTime = arrivalTime;
    }
}
