import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Review6new {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		int size = UserInput.nextInt();
		int[] moments = new int[num];
		int[] times = new int[num];
		for (int i = 0; i < num; i++) {
			moments[i] = UserInput.nextInt();
			times[i] = UserInput.nextInt();
		}
		Queue<Long> queries = new LinkedList<>();
		long next = 0;
		for (int i = 0; i < num; i++) {
			while (!queries.isEmpty() && queries.peek() <= moments[i]) {
				queries.remove();
			}
			if (queries.size() <= size) {
				next = Math.max(next, (long)moments[i]) + (long)times[i];
				System.out.print(next + " ");
				queries.add(next);
			} else {
				System.out.print(-1 + " ");
			}
		}
		UserInput.close();
	}

}


import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Review6 {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		int size = UserInput.nextInt();
		int[] moments = new int[num];
		int[] times = new int[num];
		for (int i = 0; i < num; i++) {
			moments[i] = UserInput.nextInt();
			times[i] = UserInput.nextInt();
		}
		Queue<Integer> queries = new LinkedList<>();
		Queue<Long> output = new LinkedList<>();
		long next = moments[0] + times[0];
		queries.add(0);
		output.add(next);
		long sum = 0;
		for (int i = 1; i < num; i++) {
			if (moments[i] >= next) {
				queries.remove();
				int temp = queries.remove();
				sum -= (long)times[temp];
				next = next + (long)times[temp];
				output.add(next + (long)times[i]);
				queries.add(temp);
				queries.add(i);
			}
			else if (queries.size() <= size) {
				queries.add(i);
				sum += (long)times[i];
				output.add(next + sum);
			} else {
				output.add((long)-1);
			}
		}
		while (!output.isEmpty()) {
			System.out.print(output.remove() + " ");
		}
		UserInput.close();
	}

}


import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Review6 {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		int size = UserInput.nextInt();
		int[] moments = new int[num];
		int[] times = new int[num];
		for (int i = 0; i < num; i++) {
			moments[i] = UserInput.nextInt();
			times[i] = UserInput.nextInt();
		}
		Queue<Integer> queries = new LinkedList<>();
		Queue<Long> output = new LinkedList<>();
		Queue<Integer> wrongs = new LinkedList<>();
		long next = moments[0] + times[0];
		output.add(next);
		for (int i = 1; i < num; i++) {
			if (moments[i] < next) {
				if (queries.size() < size) {
					queries.add(i);
				} else {
					wrongs.add(output.size() + queries.size());
				}
			} else {
				queries.add(i);
				while (moments[i] >= next) {
					int temp = queries.remove();
					if (queries.isEmpty()) {
						next = moments[i] + times[i];
					} else
						next = next + times[temp];
					output.add((long)next);
				}
			}
		}
		int count = 0;
		while (!output.isEmpty()) {
			while (!wrongs.isEmpty() && wrongs.peek() == count) {
				System.out.print(-1 + " ");
				wrongs.remove();
			}
			System.out.print(output.remove() + " ");
			count++;
		}
		while (!queries.isEmpty()) {
			while (!wrongs.isEmpty() && wrongs.peek() == count) {
				System.out.print(-1 + " ");
				wrongs.remove();
			}
			next += times[queries.remove()];
			System.out.print(next + " ");
			count++;
		}
		while (!wrongs.isEmpty() && wrongs.peek() == count) {
			System.out.print(-1 + " ");
			wrongs.remove();
		}
		UserInput.close();
	}

}


import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Review6 {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		int size = UserInput.nextInt();
		int[] moments = new int[num];
		int[] times = new int[num];
		for (int i = 0; i < num; i++) {
			moments[i] = UserInput.nextInt();
			times[i] = UserInput.nextInt();
		}
		Queue<Integer> queries = new LinkedList<>();
		Queue<Integer> output = new LinkedList<>();
		int next = moments[0] + times[0];
		queries.add(0);
		output.add(next);
		for (int i = 1; i < num; i++) {
			if (moments[i] >= next) {
				queries.remove();
				int temp = queries.remove();
				next = next + times[temp];
				output.add(next + times[i]);
				queries.add(temp);
				queries.add(i);
			}
			else if (queries.size() <= size) {
				queries.add(i);
				output.add(next + times[i]);
			} else {
				output.add(-1);
			}
		}
		while (!output.isEmpty()) {
			System.out.print(output.remove() + " ");
		}
		UserInput.close();
	}

}


import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Review6 {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		int size = UserInput.nextInt();
		int[] moments = new int[num];
		int[] times = new int[num];
		for (int i = 0; i < num; i++) {
			moments[i] = UserInput.nextInt();
			times[i] = UserInput.nextInt();
		}
		Queue<Integer> queries = new LinkedList<>();
		Queue<Long> output = new LinkedList<>();
		long next = moments[0] + times[0];
		queries.add(0);
		output.add(next);
		long sum = 0;
		for (int i = 1; i < num; i++) {
			if (moments[i] >= next) {
				if (queries.size() <= 1) {
					queries.remove();
					queries.add(i);
					next += (long)times[i];
					output.add(next);
				} else {
					queries.remove();
					int temp = queries.remove();
					sum -= (long)times[temp];
					next = next + (long)times[temp];
					sum += (long)times[i];
					output.add(next + sum);
					queries.add(temp);
					queries.add(i);
				}
			}
			else if (queries.size() <= size) {
				queries.add(i);
				sum += (long)times[i];
				output.add(next + sum);
			} else {
				output.add((long)-1);
			}
			System.out.println(next + " " + sum);
		}
		while (!output.isEmpty()) {
			System.out.print(output.remove() + " ");
		}
		UserInput.close();
	}

}


import javax.print.attribute.IntegerSyntax;
import java.util.*;
import java.io.IOException;
public class Task2 {
    static final int INF = Integer.MAX_VALUE;
    static void mergeSort(int[] a, int[] b, int p, int r) {
        if (p < r) {
            int q = (p + r) >> 1;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, int[] b, int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
        int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {

                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int b = in.nextInt();
            LinkedList<Long> ans= new LinkedList<>();
        for (int i = 0; i < n; i++) {
            long t=in.nextLong();
            long d= in.nextLong();
            while (ans.size()>0&&ans.element()<=t)ans.remove();
            if (ans.size()<=b){
                if (ans.size()>0)ans.getLast();
                t+=d;
                System.out.print(t+" ");
                ans.add(t);
            }
            else System.out.print(-1+" ");
        }

    }

    }
class  Pop {
    int x,y;
    public Pop(int x,int y){
        this.x=x;
        this.y=y;

    }
}


import javax.print.attribute.IntegerSyntax;
import java.util.*;
import java.io.IOException;
public class Task2 {
    static final int INF = Integer.MAX_VALUE;
    static void mergeSort(int[] a, int[] b, int p, int r) {
        if (p < r) {
            int q = (p + r) >> 1;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, int[] b, int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
        int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {

                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int b = in.nextInt();
            LinkedList<Long> ans= new LinkedList<>();
        for (int i = 0; i < n; i++) {
            long t=in.nextLong();
            long d= in.nextLong();
            while (ans.size()>0&&ans.element()<=t)ans.remove();
            if (ans.size()<=b){
                if (ans.size()>0)t=ans.getLast();
                t+=d;
                System.out.print(t+" ");
                ans.add(t);
            }
            else System.out.print(-1+" ");
        }

    }

    }
class  Pop {
    int x,y;
    public Pop(int x,int y){
        this.x=x;
        this.y=y;

    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    class Query {
        int index;
        long duration;

        Query(int index, long duration) {
            this.index = index;
            this.duration = duration;
        }
    }

    public void solve() {
        int n = in.ni(), b = in.ni();
        List<Query> queue = new ArrayList<>();
        long[] result = new long[n];
        long busyUntil = in.nl() + in.nl();
        result[0] = busyUntil;
        for (int i = 1; i < n; i++) {
            long arrival = in.nl();
            long duration = in.nl();
            Query query = new Query(i, duration);
            if (arrival < busyUntil) {
                if (queue.size() == b) {
                    result[i] = -1;
                } else {
                    queue.add(query);
                }
            } else {
                if (queue.isEmpty()) {
                    busyUntil = arrival + duration;
                    result[i] = busyUntil;
                } else {
                    Query top = queue.get(0);
                    busyUntil += top.duration;
                    queue.remove(0);
                    result[top.index] = busyUntil;
                    queue.add(query);
                    if (busyUntil < arrival) busyUntil = arrival;
                }
            }
        }
        for (Query query : queue) {
            busyUntil += query.duration;
            result[query.index] = busyUntil;
        }
        for (long i : result) {
            out.print(i + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    class Query {
        int index;
        long duration;

        Query(int index, long duration) {
            this.index = index;
            this.duration = duration;
        }
    }

    public void solve() {
        int n = in.ni(), b = in.ni();
        List<Query> queue = new ArrayList<>();
        long[] result = new long[n];
        long busyUntil = in.nl() + in.nl();
        result[0] = busyUntil;
        for (int i = 1; i < n; i++) {
            long arrival = in.nl();
            long duration = in.nl();
            Query query = new Query(i, duration);
            if (arrival < busyUntil) {
                if (queue.size() == b) {
                    result[i] = -1;
                } else {
                    queue.add(query);
                }
            } else {
                if (queue.isEmpty()) {
                    busyUntil = arrival + duration;
                    result[i] = busyUntil;
                } else {
                    Query top = queue.get(0);
                    busyUntil += top.duration;
                    queue.remove(0);
                    result[top.index] = busyUntil;
                    queue.add(query);
                    if (busyUntil <= arrival) busyUntil = arrival;
                }
            }
        }
        for (Query query : queue) {
            busyUntil += query.duration;
            result[query.index] = busyUntil;
        }
        for (long i : result) {
            out.print(i + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    class Query {
        int index;
        long duration;

        Query(int index, long duration) {
            this.index = index;
            this.duration = duration;
        }
    }

    public void solve() {
        int n = in.ni(), b = in.ni();
        List<Query> queue = new ArrayList<>();
        long[] result = new long[n];
        long busyUntil = in.nl() + in.nl();
        result[0] = busyUntil;
        for (int i = 1; i < n; i++) {
            long arrival = in.nl();
            long duration = in.nl();
            Query query = new Query(i, duration);
            if (arrival < busyUntil) {
                if (queue.size() == b) {
                    result[i] = -1;
                } else {
                    queue.add(query);
                }
            } else {
                if (queue.isEmpty()) {
                    busyUntil = arrival + duration;
                    result[i] = busyUntil;
                } else {
                    Query top = queue.get(0);
                    busyUntil += top.duration;
                    queue.remove(0);
                    result[top.index] = busyUntil;
                    queue.add(query);
                }
            }
        }
        for (Query query : queue) {
            busyUntil += query.duration;
            result[query.index] = busyUntil;
        }
        for (long i : result) {
            out.print(i + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    class Query {
        int index;
        long duration;

        Query(int index, long duration) {
            this.index = index;
            this.duration = duration;
        }
    }

    public void solve() {
        int n = in.ni(), b = in.ni();
        List<Query> queue = new ArrayList<>();
        long[] result = new long[n];
        long busyUntil = in.nl() + in.nl();
        result[0] = busyUntil;
        for (int i = 1; i < n; i++) {
            long arrival = in.nl();
            long duration = in.nl();
            Query query = new Query(i, duration);
            if (arrival < busyUntil) {
                if (queue.size() == b) {
                    result[i] = -1;
                } else {
                    queue.add(query);
                }
            } else {
                if (queue.isEmpty()) {
                    busyUntil += duration;
                    result[i] = busyUntil;
                } else {
                    Query top = queue.get(0);
                    busyUntil += top.duration;
                    queue.remove(0);
                    result[top.index] = busyUntil;
                    queue.add(query);
                }
            }
        }
        for (Query query : queue) {
            busyUntil += query.duration;
            result[query.index] = busyUntil;
        }
        for (long i : result) {
            out.print(i + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    class Query {
        int index;
        int duration;

        Query(int index, int duration) {
            this.index = index;
            this.duration = duration;
        }
    }

    public void solve() {
        int n = in.ni(), b = in.ni();
        List<Query> queue = new ArrayList<>();
        int[] result = new int[n];
        int busyUntil = in.ni() + in.ni();
        result[0] = busyUntil;
        for (int i = 1; i < n; i++) {
            int arrival = in.ni();
            int duration = in.ni();
            Query query = new Query(i, duration);
            if (arrival < busyUntil) {
                if (queue.size() == b) {
                    result[i] = -1;
                } else {
                    queue.add(query);
                }
            } else {
                if (queue.isEmpty()) {
                    busyUntil += duration;
                    result[i] = busyUntil;
                } else {
                    Query top = queue.get(0);
                    busyUntil += top.duration;
                    queue.remove(0);
                    result[top.index] = busyUntil;
                    queue.add(query);
                }
            }
        }
        for (Query query : queue) {
            busyUntil += query.duration;
            result[query.index] = busyUntil;
        }
        for (int i : result) {
            out.print(i + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    public void solve() {
        int n = in.ni(), b = in.ni();
        long[] time = new long[n];
        long[] duration = new long[n];
        long[] end = new long[n];
        Queue<Integer> q = new ArrayDeque<>();
        long free = 0;
        for (int i = 0; i < n; i++) {
            time[i] = in.ni();
            duration[i] = in.ni();
            while (free <= time[i] && q.size() > 0) {
                int id = q.poll();
                free = Math.max(free, time[id]) + duration[id];
                end[id] = free;
            }
            if (q.size() < b) {
                q.add(i);
            } else {
                end[i] = -1;
            }
        }
        while (q.size() > 0) {
            int id = q.poll();
            free = Math.max(free, time[id]) + duration[id];
            end[id] = free;
        }
        for (int i = 0; i < n; i++) {
            out.print(end[i] + " ");
        }
        out.println();
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

public class ProcessingQueries implements Closeable {

    private InputReader in = new InputReader(System.in);
    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);

    public void solve() {
        int n = in.ni(), b = in.ni();
        long[] time = new long[n];
        long[] duration = new long[n];
        long[] end = new long[n];
        Queue<Integer> q = new ArrayDeque<>();
        long free = 0;
        for (int i = 0; i < n; i++) {
            time[i] = in.ni();
            duration[i] = in.ni();
            while (free <= time[i] && q.size() > 0) {
                int id = q.poll();
                free = Math.max(free, time[id]) + duration[id];
                end[id] = free;
            }
            if (q.size() < b) {
                q.add(i);
            } else {
                end[i] = -1;
            }
        }
        while (q.size() > 0) {
            int id = q.poll();
            free = Math.max(free, time[id]) + duration[id];
            end[id] = free;
        }
        for (int i = 0; i < n; i++) {
            out.print(end[i] + " ");
        }
    }

    @Override
    public void close() throws IOException {
        in.close();
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

        public long nl() {
            return Long.parseLong(next());
        }

        public void close() throws IOException {
            reader.close();
        }
    }

    public static void main(String[] args) {
        new ProcessingQueries().solve();
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;

		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);

		TaskB solver = new TaskB();
		solver.solve(in, out);

		out.close();
	}

}

class TaskB {

	public void solve(InputReader in, OutputWriter out) {
		int n = in.nextInt();
		int b = in.nextInt();
		q = new LinkedList<Query>();

		long[] ans = new long[n];

		for(int i = 0; i < n; i++) {
			long t = in.nextInt();
			long d = in.nextInt();

			long end = q.isEmpty() ? t : q.getFirst().start+q.getFirst().d;

			while(!q.isEmpty() && end <= t) {
				ans[q.getFirst().index] = end;
				q.removeFirst();
				if(!q.isEmpty()) {
					q.getFirst().start = end;
				}
				end = q.isEmpty() ? t : q.getFirst().start + q.getFirst().d;
			}

			if(q.size() == b + 1) {
				ans[i] = -1;
			} else {
				q.addLast(new Query(end, t, d, i));
			}
		}

		while(!q.isEmpty()) {
			long end = q.getFirst().start + q.getFirst().d;
			ans[q.getFirst().index] = end;
			q.removeFirst();
			if(!q.isEmpty()) {
				q.getFirst().start = end;
			}
		}

		for(int i = 0; i < n; i++) {
			out.write(ans[i] + " ");
		}
	}

	int n, b;
	LinkedList<Query> q;

}

class Query {

	public Query(long start, long t, long d, int index) {
		this.start = start;
		this.t = t;
		this.d = d;
		this.index = index;
	}

	long start, t, d;
	int index;
}

class InputReader {

	public InputReader(InputStream inputStream) {
		tokenizer = null;
		reader = new BufferedReader(new InputStreamReader(inputStream));
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

		return tokenizer.nextToken();
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	StringTokenizer tokenizer;
	BufferedReader reader;
}

class OutputWriter {

	public OutputWriter(OutputStream outputStream) {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				outputStream)));
	}

	public void write(Object... o) {
		for (Object x : o)
			out.print(x);
	}

	public void writeln(Object... o) {
		write(o);
		out.println();
	}

	public void close() {
		out.close();
	}

	PrintWriter out;
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;

		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);

		TaskB solver = new TaskB();
		solver.solve(in, out);

		out.close();
	}

}

class TaskB {

	public void solve(InputReader in, OutputWriter out) {
		int n = in.nextInt();
		int b = in.nextInt();
		q = new LinkedList<Query>();

		int[] ans = new int[n];

		for(int i = 0; i < n; i++) {
			int t = in.nextInt();
			int d = in.nextInt();

			int end = q.isEmpty() ? t : q.getFirst().start+q.getFirst().d;

			while(!q.isEmpty() && end <= t) {
				ans[q.getFirst().index] = end;
				q.removeFirst();
				if(!q.isEmpty()) {
					q.getFirst().start = end;
				}
				end = q.isEmpty() ? t : q.getFirst().start + q.getFirst().d;
			}

			if(q.size() == b + 1) {
				ans[i] = -1;
			} else {
				q.addLast(new Query(end, t, d, i));
			}
		}

		while(!q.isEmpty()) {
			int end = q.getFirst().start + q.getFirst().d;
			ans[q.getFirst().index] = end;
			q.removeFirst();
			if(!q.isEmpty()) {
				q.getFirst().start = end;
			}
		}

		for(int i = 0; i < n; i++) {
			out.write(ans[i] + " ");
		}
	}

	int n, b;
	LinkedList<Query> q;

}

class Query {

	public Query(int start, int t, int d, int index) {
		this.start = start;
		this.t = t;
		this.d = d;
		this.index = index;
	}

	int start, t, d, index;
}

class InputReader {

	public InputReader(InputStream inputStream) {
		tokenizer = null;
		reader = new BufferedReader(new InputStreamReader(inputStream));
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

		return tokenizer.nextToken();
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	StringTokenizer tokenizer;
	BufferedReader reader;
}

class OutputWriter {

	public OutputWriter(OutputStream outputStream) {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				outputStream)));
	}

	public void write(Object... o) {
		for (Object x : o)
			out.print(x);
	}

	public void writeln(Object... o) {
		write(o);
		out.println();
	}

	public void close() {
		out.close();
	}

	PrintWriter out;
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.io.*;
public class codeforces
{
   static class Student{
       int x,y,z;
        Student(int x,int y,int z){
            this.x=x;
            this.y=y;
            this.z=z;
        }
    }
    static int prime[];
    static void sieveOfEratosthenes(int n)
    {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.
        int pos=0;
        prime= new int[n+1];
        for(int p = 2; p*p <=n; p++)
        {
            // If prime[p] is not changed, then it is a prime
            if(prime[p] == 0)
            {
                // Update all multiples of p
                prime[p]=p;
                for(int i = p*p; i <= n; i += p)
                    if(prime[i]==0)
                    prime[i] = p;
            }
        }
    }
static    class Sortbyroll implements Comparator<Student>
{
    // Used for sorting in ascending order of
    // roll number
    public int compare(Student c, Student b)
    {
        if(b.y>c.y)
            return -1;
        if(b.y<c.y)
            return 1;
        if(b.x>c.x)
            return -1;
        return 1;
    }
}
static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Edge{
        int a,b;
        Edge(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
    static class Trie{
        HashMap<Character,Trie>map;
         int c;
        Trie(){
            map=new HashMap<>();
            //z=null;
            //o=null;
            c=0;
        }
    }
    //static long ans;
    static int parent[];
    static int rank[];
   // static int b[][];
    static int bo[];
    static int ho[];
    static int seg[];
    //static int pos;
     static long mod=1000000007;
    //static int dp[][];
    static HashMap<Integer,Integer>map;
    static PriorityQueue<Student>q=new PriorityQueue<>();
    //static Stack<Integer>st;
   // static ArrayList<Character>ans;
    static ArrayList<ArrayList<Integer>>adj;
    //static long ans;
    static int pos;
    static Trie root;
    static long fac[];
    static int gw,gb;
    //static long mod=(long)(998244353);
    //static int ans;
    static void solve()throws IOException{
        FastReader sc=new FastReader();
        int n,b,i,y,z;
        long s=0;
        n=sc.nextInt();
        b=sc.nextInt();
        StringBuilder sb=new StringBuilder();
        long ans[]=new long[n];
        Queue<Student>q=new LinkedList<>();
        for(i=0;i<n;i++){
            y=sc.nextInt();
            z=sc.nextInt();
                if((long)y>=s){
                    while(!q.isEmpty()&&s<=(long)y){
                    ans[q.peek().z]=(long)Math.max(s,(long)q.peek().x)+(long)q.peek().y;
                    s=(long)Math.max(s,(long)q.peek().x)+(long)q.peek().y;
                        q.poll();
                    }
                    if(q.isEmpty()&&s<=(long)y){
                     ans[i]=(long)Math.max((long)y,s)+(long)z;
                     s=(long)Math.max((long)y,s)+(long)z;
                    }
                    else if(q.size()<b)
                    q.add(new Student(y,z,i));
                }
                else{
                    if(q.size()<b){
                        q.add(new Student(y,z,i));
                    }
                }
        }
        while(!q.isEmpty()){
            ans[q.peek().z]=(long)Math.max(s,(long)q.peek().x)+(long)q.peek().y;
            s=(long)Math.max(s,(long)q.peek().x)+(long)q.peek().y;
                    //q.poll();
            q.poll();
        }
        for(i=0;i<n;i++){
            if(ans[i]==0){
                sb.append(-1+" ");
            }
            else
                sb.append(ans[i]+" ");
        }
        System.out.println(sb.toString());
    }
    static long fac(long x,long y){
        if(y==0||x==0)
            return 1;
        return x * fac(x-1,y-1);
    }
    static long nCr(long n, long r,
                                    long p)
    {
        return (fac[(int)n]* modInverse(fac[(int)r], p)
                % p * modInverse(fac[(int)(n-r)], p)
                                    % p) % p;
    }
    //static int prime[];
    //static int dp[];
    public static void main(String[] args){
        //long sum=0;
        try {
                codeforces.solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }
       static long modInverse(long n, long p)
    {
        return power(n, p-(long)2,p);
    }
 static long power(long x, long y, long p)
{
    long res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %(long)2!=0)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res%p;
 }
    /*public static long power(long x,long a) {
		if(a==0) return 1;
		if(a%2==1)return (x*1L*power(x,a-1))%mod;
		return (power((int)((x*1L*x)%mod),a/2))%mod;
	}*/
   static int find(int x)
    {
        // Finds the representative of the set
        // that x is an element of
        while(parent[x]!=x)
        {
            // if x is not the parent of itself
            // Then x is not the representative of
            // his set,
            x=parent[x];

            // so we recursively call Find on its parent
            // and move i's node directly under the
            // representative of this set
        }

        return x;
    }
    static void union(int x, int y)
    {
        // Find representatives of two sets
        int xRoot = find(x), yRoot = find(y);

        // Elements are in the same set, no need
        // to unite anything.
        if (xRoot == yRoot)
            return;

         // If x's rank is less than y's rank
        if (rank[xRoot] < rank[yRoot])

            // Then move x under y  so that depth
            // of tree remains less
            parent[xRoot] = yRoot;

        // Else if y's rank is less than x's rank
        else if (rank[yRoot] < rank[xRoot])

            // Then move y under x so that depth of
            // tree remains less
            parent[yRoot] = xRoot;

        else // if ranks are the same
        {
            // Then move y under x (doesn't matter
            // which one goes where)
            parent[yRoot] = xRoot;

            // And increment the the result tree's
            // rank by 1
            rank[xRoot] = rank[xRoot] + 1;
        }
    }
    static long gcd(long a, long b)
    {
        if (a == 0){
             //ans+=b;
            return b;
        }
        return gcd(b % a, a);
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class ServerRequestProblem {
    public static void main(String[]args) {
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int n = s.nextInt();
        int b = s.nextInt();

        int t, d;
        ArrayDeque<Integer> buff = new ArrayDeque<>(b+1);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n; i++) {
            t=s.nextInt();
            d=s.nextInt();
            if (buff.size() == b+1  &&  buff.getFirst() > t) {
                sb.append("-1 ");
                continue;
            }
            while (!buff.isEmpty() && buff.getFirst() <= t) {
                buff.removeFirst();
            }
            if (!buff.isEmpty()) {
                if (buff.getLast() < t) {
                    buff.addLast(t + d);
                    sb.append(String.valueOf(t + d));
                } else {
                    t=buff.getLast()+d;
                    buff.addLast(t);
                    sb.append(String.valueOf(t));
                }
            } else {
                buff.addLast(t+d);
                sb.append(String.valueOf(t + d));
            }
            sb.append(' ');
        }

        System.out.println(sb.toString());
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.Scanner;

public class LongServerRequestProblem {
    public static void main(String[]args) {
        Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int n = s.nextInt();
        int b = s.nextInt();

        long t, d;
        ArrayDeque<BigInteger> buff = new ArrayDeque<>(b+1);

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n; i++) {
            t=s.nextLong();
            d=s.nextLong();
            if (buff.size() == b+1  &&  buff.getFirst().compareTo(BigInteger.valueOf(t)) > 0) {
                sb.append("-1 ");
                continue;
            }
            while (!buff.isEmpty() && buff.getFirst().compareTo(BigInteger.valueOf(t)) <= 0) {
                buff.removeFirst();
            }
            if (!buff.isEmpty()) {
                    BigInteger tn=buff.getLast().add(BigInteger.valueOf(d));
                    buff.addLast(tn);
                    sb.append(String.valueOf(tn));
            } else {
                buff.addLast(BigInteger.valueOf(t + d));
                sb.append(String.valueOf(t+d));
            }
            sb.append(' ');
        }

        System.out.println(sb.toString());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class B {
	public static void main(String[] args) {
		MyScanner scan = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int Q = scan.nextInt(), max = scan.nextInt();

		int curr = 0;

		PriorityQueue<Query> q = new PriorityQueue<>();
		Queue<Query> server = new LinkedList<>();
		long[] val = new long[Q];
		for(int i=0;i<Q;i++)q.add(new Query(i, scan.nextLong(), scan.nextLong(), true));

		while(!q.isEmpty()){
			Query k = q.poll();
			if(k.type){
				if(curr==max){val[k.ord]=-1;continue;}
				if(server.size()==0){
					k.time+=k.effort;
					k.type=false;
					q.add(k);
					server.add(k);
				}else{
					curr++;
					k.type=false;
					server.add(k);
				}
			}else{
				curr--;
				val[k.ord]=k.time;
				if(server.size()!=1){
					server.poll();
					long time = k.time;
					Query next = server.peek();
					next.time=time+next.effort;
					q.add(next);
				}else{server.poll();}
			}
		}
		for(long l : val)System.out.print(l+" ");System.out.println();
		out.close();

	}
	private static class Query implements Comparable<Query> {

		long time;
		long effort;
		int ord;
		boolean type;//true means start, false means stop;
		public Query (int ord, long time, long effort, boolean type){
			this.ord = ord;
			this.time = time;
			this.effort=effort;
			this.type = type;
		}
		public int compareTo(Query q) {
			if(this.time < q.time)return -1;
			else if (this.time > q.time)return 1;
			else {
				if(!this.type && q.type)return -1;
				else return 1;
			}
		}

	}
	private static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;
	    public MyScanner(){
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try { st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {e.printStackTrace();}
	        }
	        return st.nextToken();
	    }
	    int nextInt() {
	    	return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	 }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class B {
	public static void main(String[] args) {
		MyScanner scan = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int Q = scan.nextInt(), max = scan.nextInt();

		int curr = 0;

		PriorityQueue<Query> q = new PriorityQueue<>();
		Queue<Query> server = new LinkedList<>();
		long[] val = new long[Q];
		for(int i=0;i<Q;i++)q.add(new Query(i, scan.nextLong(), scan.nextLong(), true));

		while(!q.isEmpty()){
			Query k = q.poll();
			if(k.type){
				if(curr==max){val[k.ord]=-1;continue;}
				if(server.size()==0){
					k.time+=k.effort;
					k.type=false;
					q.add(k);
					server.add(k);
				}else{
					curr++;
					k.type=false;
					server.add(k);
				}
			}else{
				if(curr>0)curr--;
				val[k.ord]=k.time;
				if(server.size()!=1){
					server.poll();
					long time = k.time;
					Query next = server.peek();
					next.time=time+next.effort;
					q.add(next);
				}else{server.poll();}
			}
		}
		for(long l : val)System.out.print(l+" ");System.out.println();
		out.close();

	}
	private static class Query implements Comparable<Query> {

		long time;
		long effort;
		int ord;
		boolean type;//true means start, false means stop;
		public Query (int ord, long time, long effort, boolean type){
			this.ord = ord;
			this.time = time;
			this.effort=effort;
			this.type = type;
		}
		public int compareTo(Query q) {
			if(this.time < q.time)return -1;
			else if (this.time > q.time)return 1;
			else {
				if(!this.type && q.type)return -1;
				else return 1;
			}
		}

	}
	private static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;
	    public MyScanner(){
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try { st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {e.printStackTrace();}
	        }
	        return st.nextToken();
	    }
	    int nextInt() {
	    	return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	 }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/*
 * Author    : joney_000[let_me_start]
 * Algorithm :
 * Platform  :
 *
 */

/*    The Main Class                */
 public class A{

	private InputStream inputStream ;
	private OutputStream outputStream ;
	private FastReader in ;
    	private PrintWriter out ;
	/*
		Overhead [Additional Temporary Strorage] but provides memory reusibility for multiple test cases.

	*/

	//Critical Size Limit : 10^5 + 4
	private final int BUFFER = 100005;
	private int    tempints[] = new int[BUFFER];
	private long   templongs[] = new long[BUFFER];
	private double tempdoubles[] = new double[BUFFER];
	private char   tempchars[] = new char[BUFFER];
	private final long mod = 1000000000+7;
	private final int  INF  = Integer.MAX_VALUE / 10;
	private final long INF_L  = Long.MAX_VALUE / 10;

	public A(){}
	public A(boolean stdIO)throws FileNotFoundException{
		//stdIO = false;
		if(stdIO){
			inputStream = System.in;
			outputStream = System.out;
		}else{
			inputStream = new FileInputStream("laundro_matt.txt");
			outputStream = new FileOutputStream("output.txt");
		}
		in = new FastReader(inputStream);
		out = new PrintWriter(outputStream);

	}

  	void run()throws Exception{

	//	 int tests = i();
	//	 once();
	//	 for(int t  = 1 ; t<= tests ; t++){
	//	 	clear(n);
		 	int n = i(); int b = i();
		 	Pair[] p = new Pair[n+1];

		 	for(int i  =1 ; i<= n ; i++)p[i] = new Pair(i,i(),i(),0);
		 	LinkedList <Integer>ll = new LinkedList<Integer>();
		 	LinkedList <Integer>remain = new LinkedList<Integer>();
		 	for(int i  =2 ; i<= n ; i++)remain.add(i);
		 	ll.add(1);
		 	int time = 0;
		 	int q = 0;
		 	for(int i =1 ; i<= n ; i++){
		 		if(ll.isEmpty())break;
		 		int curr = (Integer)ll.removeFirst();
		 		int st = Math.max(p[curr].a , time);
		 		int end = st + p[curr].b;
		 		time = end;
		 		p[curr].c = time;
		 		while(!remain.isEmpty() && p[(Integer)remain.getFirst()].a < end){
		 			if(ll.size() >= b){
		 				int rem = remain.removeFirst();
		 				p[rem].c = -1;
		 			}else{
		 				int rem = remain.removeFirst();
		 				ll.add(rem);
		 			}
		 		}

		 	}
		 	for(int i = 1 ; i <= n ; i++)out.write(""+p[i].c+" ");
	//	}//end tests
	}//end run
	void once(){

	}
	void clear(int n){

	}

//****************************** My Utilities ***********************//
 	void print_r(Object...o){
       	out.write("\n"+Arrays.deepToString(o)+"\n");
        	out.flush();
	}

	int hash(String s){
		int base = 31;
		int a = 31;//base = a multiplier
		int mod = 100005;//range [0..100004]
		long val = 0;
		for(int i =  1 ; i<= s.length() ;i++){
			val += base * s.charAt(i-1);
			base = ( a * base ) % 100005;
		}
		return (int)(val % 100005) ;
	}

 	boolean isPrime(long n){
  		if(n==1)return false;
  		if(n<=3)return true;
  		if(n%2==0)return false;
  		for(int i=2 ;i <= Math.sqrt(n); i++){
   			if(n%i==0)return false;
  		}
  		return true;
 	}
 	// sieve
 	int[] sieve(int n){

  		boolean isPrime[] = new boolean[n+1];
  		int p[] = new int[n+1];
  		int idx = 1;
  		// Put above 3 variables globle p[1..idx-1]

  		Arrays.fill(isPrime,true);
  		isPrime[0]=isPrime[1]=false;
  		for(int i = 2 ; i<= n ; i++){
  			if(isPrime[i]){
  				p[idx++] = i;
  				for(int j  = 2* i ; j<= n ; j+=i ){
  					isPrime[j] = false;
  				}

  			}

  		}
  		return p;
 	}
 	long gcd(long a , long b){
  		if(b==0)return a;
  		return gcd(b , a%b);
 	}
 	long lcm(long a , long b){
  		if(a==0||b==0)return 0;
  		return (a*b)/gcd(a,b);
 	}
 	long mulmod(long a , long b ,long mod){
  		if(a==0||b==0)return 0;
  		if(b==1)return a;
   		long ans = mulmod(a,b/2,mod);
   		ans = (ans*2)% mod;
   		if(b%2==1)ans = (a + ans)% mod;
   		return ans;
 	}
 	long pow(long a , long b ,long mod){
   		if(b==0)return 1;
  		if(b==1)return a;
   		long ans = pow(a,b/2,mod);
   		ans = (ans * ans);
   		if(ans >= mod )ans %= mod;

   		if(b%2==1)ans = (a * ans);
   		if(ans >= mod )ans %= mod;

   		return ans;
 	}
 	// 20*20   nCr Pascal Table
 	long[][] ncrTable(){
  		long ncr[][] = new long[21][21];
  		for(int i=0 ;i<=20 ;i++){ncr[i][0]=1;ncr[i][i]=1;}
  		for(int j=0;j<=20 ;j++){
   			for(int i=j+1;i<= 20 ;i++){
    				ncr[i][j] = ncr[i-1][j]+ncr[i-1][j-1];
   			}
  		}
  	return ncr;
 	}
	//*******************************I/O******************************//
	int i()throws Exception{
 		//return Integer.parseInt(br.readLine().trim());
 		return in.nextInt();
	}
	int[] is(int n)throws Exception{
  //int arr[] = new int[n+1];
  		for(int i=1 ; i <= n ;i++)tempints[i] = in.nextInt();
 		return tempints;
	}
	long l()throws Exception{
 		return in.nextLong();
	}
	long[] ls(int n)throws Exception{
 		for(int i=1 ; i <= n ;i++)templongs[i] = in.nextLong();
 		return templongs;
	}

	double d()throws Exception{
 		return in.nextDouble();
	}
	double[] ds(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempdoubles[i] = in.nextDouble();
 		return tempdoubles;
	}
	char c()throws Exception{
 		return in.nextCharacter();
	}
	char[] cs(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempchars[i] = in.nextCharacter();
 		return tempchars;
	}
	String s()throws Exception{
 		return in.nextLine();
	}
	BigInteger bi()throws Exception{
 		return in.nextBigInteger();
	}
//***********************I/O ENDS ***********************//
//*********************** 0.3%f [precision]***********************//
/* roundoff upto 2 digits
   double roundOff = Math.round(a * 100.0) / 100.0;
                    or
   System.out.printf("%.2f", val);

*/
/*
  print upto 2 digits after decimal
  val = ((long)(val * 100.0))/100.0;

*/    private void closeResources(){
		 	 out.flush();
    		 out.close();
    		 return;
	}
	public static void main(String[] args) throws java.lang.Exception{
		//let_me_start Shinch Returns

    /*
    	  // Old Reader Writer
    	  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
	  BufferedReader br=new BufferedReader(new FileReader("input.txt"));
        BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"));
    */
    		 A driver = new A(true);
    		 long start =  System.currentTimeMillis();
    		 driver.run();
    		 long end =  System.currentTimeMillis();
    		 //out.write(" Total Time : "+(end - start)+"\n");
    		 driver.closeResources();
    		 return ;

	}

}

class FastReader{

	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[4*1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public FastReader(InputStream stream){
		this.stream = stream;
	}

	public int read(){
		if (numChars == -1){
			throw new InputMismatchException ();
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				throw new InputMismatchException ();
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar++];
	}

	public int peek(){
		if (numChars == -1){
			return -1;
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				return -1;
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar];
	}

	public int nextInt(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		int res = 0;
		do{
			if(c==','){
				c = read();
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public long nextLong(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		long res = 0;
		do{
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public String nextString(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		StringBuilder res = new StringBuilder ();
		do{
			res.appendCodePoint (c);
			c = read ();
		} while (!isSpaceChar (c));
		return res.toString ();
	}

	public boolean isSpaceChar(int c){
		if (filter != null){
			return filter.isSpaceChar (c);
		}
		return isWhitespace (c);
	}

	public static boolean isWhitespace(int c){
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0(){
		StringBuilder buf = new StringBuilder ();
		int c = read ();
		while (c != '\n' && c != -1){
			if (c != '\r'){
				buf.appendCodePoint (c);
			}
			c = read ();
		}
		return buf.toString ();
	}

	public String nextLine(){
		String s = readLine0 ();
		while (s.trim ().length () == 0)
			s = readLine0 ();
		return s;
	}

	public String nextLine(boolean ignoreEmptyLines){
		if (ignoreEmptyLines){
			return nextLine ();
		}else{
			return readLine0 ();
		}
	}

	public BigInteger nextBigInteger(){
		try{
			return new BigInteger (nextString ());
		} catch (NumberFormatException e){
			throw new InputMismatchException ();
		}
	}

	public char nextCharacter(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		return (char) c;
	}

	public double nextDouble(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		double res = 0;
		while (!isSpaceChar (c) && c != '.'){
			if (c == 'e' || c == 'E'){
				return res * Math.pow (10, nextInt ());
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		}
		if (c == '.'){
			c = read ();
			double m = 1;
			while (!isSpaceChar (c)){
				if (c == 'e' || c == 'E'){
					return res * Math.pow (10, nextInt ());
				}
				if (c < '0' || c > '9'){
					throw new InputMismatchException ();
				}
				m /= 10;
				res += (c - '0') * m;
				c = read ();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted(){
		int value;
		while (isSpaceChar (value = peek ()) && value != -1)
			read ();
		return value == -1;
	}

	public String next(){
		return nextString ();
	}

	public SpaceCharFilter getFilter(){
		return filter;
	}

	public void setFilter(SpaceCharFilter filter){
		this.filter = filter;
	}

	public interface SpaceCharFilter{
		public boolean isSpaceChar(int ch);
	}
}
 /******************** Pair class ***********************/

 class Pair implements Comparable<Pair>{
 public int id;
 public int b;
 public int a;
 public int c;
 public Pair(){
  this.id = 1000;

  this.a = 0;
  this.b = 0;
  this.c = 0;
 }
 public Pair(int id , int a,int b , int c ){
  this.id = id;
  this.a = a;
  this.b = b;
  this.c = c;
 }
 public int compareTo(Pair p){
	if(this.a < p.a)return -1;
	else if(this.a > p.a )return 1;
	else {
		if(this.b < p.b)return -1;
		else if(this.b > p.b )return 1;
		else return 0;

	}
 }
 public String toString(){
  return "a="+this.a+" b="+this.b;
 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/*
 * Author    : joney_000[let_me_start]
 * Algorithm :
 * Platform  :
 *
 */

/*    The Main Class                */
 public class A{

	private InputStream inputStream ;
	private OutputStream outputStream ;
	private FastReader in ;
    	private PrintWriter out ;
	/*
		Overhead [Additional Temporary Strorage] but provides memory reusibility for multiple test cases.

	*/

	//Critical Size Limit : 10^5 + 4
	private final int BUFFER = 100005;
	private int    tempints[] = new int[BUFFER];
	private long   templongs[] = new long[BUFFER];
	private double tempdoubles[] = new double[BUFFER];
	private char   tempchars[] = new char[BUFFER];
	private final long mod = 1000000000+7;
	private final int  INF  = Integer.MAX_VALUE / 10;
	private final long INF_L  = Long.MAX_VALUE / 10;

	public A(){}
	public A(boolean stdIO)throws FileNotFoundException{
		//stdIO = false;
		if(stdIO){
			inputStream = System.in;
			outputStream = System.out;
		}else{
			inputStream = new FileInputStream("laundro_matt.txt");
			outputStream = new FileOutputStream("output.txt");
		}
		in = new FastReader(inputStream);
		out = new PrintWriter(outputStream);

	}

  	void run()throws Exception{

	//	 int tests = i();
	//	 once();
	//	 for(int t  = 1 ; t<= tests ; t++){
	//	 	clear(n);
		 	int n = i(); int b = i();
		 	Pair[] p = new Pair[n+1];

		 	for(int i  =1 ; i<= n ; i++)p[i] = new Pair(i,l(),l(),0);
		 	LinkedList <Integer>ll = new LinkedList<Integer>();
		 	LinkedList <Integer>remain = new LinkedList<Integer>();
		 	for(int i  =2 ; i<= n ; i++)remain.add(i);
		 	ll.add(1);
		 	long time = 0;

		 	for(int i =1 ; i<= n ; i++){
		 		if(ll.isEmpty() && remain.isEmpty())break;
		 		if(ll.isEmpty() && !remain.isEmpty())ll.add((Integer)remain.removeFirst());

		 		int curr = (Integer)ll.removeFirst();
		 		long st = Math.max(p[curr].a , time);
		 		long end = st + p[curr].b;
		 		time = end;
		 		p[curr].c = time;
		 		while(!remain.isEmpty() && p[(Integer)remain.getFirst()].a < end){
		 			if(ll.size() >= b){
		 				int rem = remain.removeFirst();
		 				p[rem].c = -1;
		 			}else{
		 				int rem = remain.removeFirst();
		 				ll.add(rem);
		 			}
		 		}

		 	}
		 	for(int i = 1 ; i <= n ; i++)out.write(""+p[i].c+" ");
	//	}//end tests
	}//end run
	void once(){

	}
	void clear(int n){

	}

//****************************** My Utilities ***********************//
 	void print_r(Object...o){
       	out.write("\n"+Arrays.deepToString(o)+"\n");
        	out.flush();
	}

	int hash(String s){
		int base = 31;
		int a = 31;//base = a multiplier
		int mod = 100005;//range [0..100004]
		long val = 0;
		for(int i =  1 ; i<= s.length() ;i++){
			val += base * s.charAt(i-1);
			base = ( a * base ) % 100005;
		}
		return (int)(val % 100005) ;
	}

 	boolean isPrime(long n){
  		if(n==1)return false;
  		if(n<=3)return true;
  		if(n%2==0)return false;
  		for(int i=2 ;i <= Math.sqrt(n); i++){
   			if(n%i==0)return false;
  		}
  		return true;
 	}
 	// sieve
 	int[] sieve(int n){

  		boolean isPrime[] = new boolean[n+1];
  		int p[] = new int[n+1];
  		int idx = 1;
  		// Put above 3 variables globle p[1..idx-1]

  		Arrays.fill(isPrime,true);
  		isPrime[0]=isPrime[1]=false;
  		for(int i = 2 ; i<= n ; i++){
  			if(isPrime[i]){
  				p[idx++] = i;
  				for(int j  = 2* i ; j<= n ; j+=i ){
  					isPrime[j] = false;
  				}

  			}

  		}
  		return p;
 	}
 	long gcd(long a , long b){
  		if(b==0)return a;
  		return gcd(b , a%b);
 	}
 	long lcm(long a , long b){
  		if(a==0||b==0)return 0;
  		return (a*b)/gcd(a,b);
 	}
 	long mulmod(long a , long b ,long mod){
  		if(a==0||b==0)return 0;
  		if(b==1)return a;
   		long ans = mulmod(a,b/2,mod);
   		ans = (ans*2)% mod;
   		if(b%2==1)ans = (a + ans)% mod;
   		return ans;
 	}
 	long pow(long a , long b ,long mod){
   		if(b==0)return 1;
  		if(b==1)return a;
   		long ans = pow(a,b/2,mod);
   		ans = (ans * ans);
   		if(ans >= mod )ans %= mod;

   		if(b%2==1)ans = (a * ans);
   		if(ans >= mod )ans %= mod;

   		return ans;
 	}
 	// 20*20   nCr Pascal Table
 	long[][] ncrTable(){
  		long ncr[][] = new long[21][21];
  		for(int i=0 ;i<=20 ;i++){ncr[i][0]=1;ncr[i][i]=1;}
  		for(int j=0;j<=20 ;j++){
   			for(int i=j+1;i<= 20 ;i++){
    				ncr[i][j] = ncr[i-1][j]+ncr[i-1][j-1];
   			}
  		}
  	return ncr;
 	}
	//*******************************I/O******************************//
	int i()throws Exception{
 		//return Integer.parseInt(br.readLine().trim());
 		return in.nextInt();
	}
	int[] is(int n)throws Exception{
  //int arr[] = new int[n+1];
  		for(int i=1 ; i <= n ;i++)tempints[i] = in.nextInt();
 		return tempints;
	}
	long l()throws Exception{
 		return in.nextLong();
	}
	long[] ls(int n)throws Exception{
 		for(int i=1 ; i <= n ;i++)templongs[i] = in.nextLong();
 		return templongs;
	}

	double d()throws Exception{
 		return in.nextDouble();
	}
	double[] ds(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempdoubles[i] = in.nextDouble();
 		return tempdoubles;
	}
	char c()throws Exception{
 		return in.nextCharacter();
	}
	char[] cs(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempchars[i] = in.nextCharacter();
 		return tempchars;
	}
	String s()throws Exception{
 		return in.nextLine();
	}
	BigInteger bi()throws Exception{
 		return in.nextBigInteger();
	}
//***********************I/O ENDS ***********************//
//*********************** 0.3%f [precision]***********************//
/* roundoff upto 2 digits
   double roundOff = Math.round(a * 100.0) / 100.0;
                    or
   System.out.printf("%.2f", val);

*/
/*
  print upto 2 digits after decimal
  val = ((long)(val * 100.0))/100.0;

*/    private void closeResources(){
		 	 out.flush();
    		 out.close();
    		 return;
	}
	public static void main(String[] args) throws java.lang.Exception{
		//let_me_start Shinch Returns

    /*
    	  // Old Reader Writer
    	  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
	  BufferedReader br=new BufferedReader(new FileReader("input.txt"));
        BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"));
    */
    		 A driver = new A(true);
    		 long start =  System.currentTimeMillis();
    		 driver.run();
    		 long end =  System.currentTimeMillis();
    		 //out.write(" Total Time : "+(end - start)+"\n");
    		 driver.closeResources();
    		 return ;

	}

}

class FastReader{

	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[4*1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public FastReader(InputStream stream){
		this.stream = stream;
	}

	public int read(){
		if (numChars == -1){
			throw new InputMismatchException ();
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				throw new InputMismatchException ();
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar++];
	}

	public int peek(){
		if (numChars == -1){
			return -1;
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				return -1;
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar];
	}

	public int nextInt(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		int res = 0;
		do{
			if(c==','){
				c = read();
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public long nextLong(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		long res = 0;
		do{
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public String nextString(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		StringBuilder res = new StringBuilder ();
		do{
			res.appendCodePoint (c);
			c = read ();
		} while (!isSpaceChar (c));
		return res.toString ();
	}

	public boolean isSpaceChar(int c){
		if (filter != null){
			return filter.isSpaceChar (c);
		}
		return isWhitespace (c);
	}

	public static boolean isWhitespace(int c){
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0(){
		StringBuilder buf = new StringBuilder ();
		int c = read ();
		while (c != '\n' && c != -1){
			if (c != '\r'){
				buf.appendCodePoint (c);
			}
			c = read ();
		}
		return buf.toString ();
	}

	public String nextLine(){
		String s = readLine0 ();
		while (s.trim ().length () == 0)
			s = readLine0 ();
		return s;
	}

	public String nextLine(boolean ignoreEmptyLines){
		if (ignoreEmptyLines){
			return nextLine ();
		}else{
			return readLine0 ();
		}
	}

	public BigInteger nextBigInteger(){
		try{
			return new BigInteger (nextString ());
		} catch (NumberFormatException e){
			throw new InputMismatchException ();
		}
	}

	public char nextCharacter(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		return (char) c;
	}

	public double nextDouble(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		double res = 0;
		while (!isSpaceChar (c) && c != '.'){
			if (c == 'e' || c == 'E'){
				return res * Math.pow (10, nextInt ());
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		}
		if (c == '.'){
			c = read ();
			double m = 1;
			while (!isSpaceChar (c)){
				if (c == 'e' || c == 'E'){
					return res * Math.pow (10, nextInt ());
				}
				if (c < '0' || c > '9'){
					throw new InputMismatchException ();
				}
				m /= 10;
				res += (c - '0') * m;
				c = read ();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted(){
		int value;
		while (isSpaceChar (value = peek ()) && value != -1)
			read ();
		return value == -1;
	}

	public String next(){
		return nextString ();
	}

	public SpaceCharFilter getFilter(){
		return filter;
	}

	public void setFilter(SpaceCharFilter filter){
		this.filter = filter;
	}

	public interface SpaceCharFilter{
		public boolean isSpaceChar(int ch);
	}
}
 /******************** Pair class ***********************/

 class Pair implements Comparable<Pair>{
 public int id;
 public long b;
 public long a;
 public long c;
 public Pair(){
  this.id = 1000;

  this.a = 0;
  this.b = 0;
  this.c = 0;
 }
 public Pair(int id , long a,long b , long c ){
  this.id = id;
  this.a = a;
  this.b = b;
  this.c = c;
 }
 public int compareTo(Pair p){
	if(this.a < p.a)return -1;
	else if(this.a > p.a )return 1;
	else {
		if(this.b < p.b)return -1;
		else if(this.b > p.b )return 1;
		else return 0;

	}
 }
 public String toString(){
  return "a="+this.a+" b="+this.b;
 }

}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/*
 * Author    : joney_000[let_me_start]
 * Algorithm :
 * Platform  :
 *
 */

/*    The Main Class                */
 public class A{

	private InputStream inputStream ;
	private OutputStream outputStream ;
	private FastReader in ;
    	private PrintWriter out ;
	/*
		Overhead [Additional Temporary Strorage] but provides memory reusibility for multiple test cases.

	*/

	//Critical Size Limit : 10^5 + 4
	private final int BUFFER = 100005;
	private int    tempints[] = new int[BUFFER];
	private long   templongs[] = new long[BUFFER];
	private double tempdoubles[] = new double[BUFFER];
	private char   tempchars[] = new char[BUFFER];
	private final long mod = 1000000000+7;
	private final int  INF  = Integer.MAX_VALUE / 10;
	private final long INF_L  = Long.MAX_VALUE / 10;

	public A(){}
	public A(boolean stdIO)throws FileNotFoundException{
		//stdIO = false;
		if(stdIO){
			inputStream = System.in;
			outputStream = System.out;
		}else{
			inputStream = new FileInputStream("laundro_matt.txt");
			outputStream = new FileOutputStream("output.txt");
		}
		in = new FastReader(inputStream);
		out = new PrintWriter(outputStream);

	}

  	void run()throws Exception{

	//	 int tests = i();
	//	 once();
	//	 for(int t  = 1 ; t<= tests ; t++){
	//	 	clear(n);
		 	int n = i(); int b = i();
		 	Pair[] p = new Pair[n+1];

		 	for(int i  =1 ; i<= n ; i++)p[i] = new Pair(i,i(),i(),0);
		 	LinkedList <Integer>ll = new LinkedList<Integer>();
		 	LinkedList <Integer>remain = new LinkedList<Integer>();
		 	for(int i  =2 ; i<= n ; i++)remain.add(i);
		 	ll.add(1);
		 	int time = 0;

		 	for(int i =1 ; i<= n ; i++){
		 		if(ll.isEmpty() && remain.isEmpty())break;
		 		if(ll.isEmpty() && !remain.isEmpty())ll.add((Integer)remain.removeFirst());

		 		int curr = (Integer)ll.removeFirst();
		 		int st = Math.max(p[curr].a , time);
		 		int end = st + p[curr].b;
		 		time = end;
		 		p[curr].c = time;
		 		while(!remain.isEmpty() && p[(Integer)remain.getFirst()].a < end){
		 			if(ll.size() >= b){
		 				int rem = remain.removeFirst();
		 				p[rem].c = -1;
		 			}else{
		 				int rem = remain.removeFirst();
		 				ll.add(rem);
		 			}
		 		}

		 	}
		 	for(int i = 1 ; i <= n ; i++)out.write(""+p[i].c+" ");
	//	}//end tests
	}//end run
	void once(){

	}
	void clear(int n){

	}

//****************************** My Utilities ***********************//
 	void print_r(Object...o){
       	out.write("\n"+Arrays.deepToString(o)+"\n");
        	out.flush();
	}

	int hash(String s){
		int base = 31;
		int a = 31;//base = a multiplier
		int mod = 100005;//range [0..100004]
		long val = 0;
		for(int i =  1 ; i<= s.length() ;i++){
			val += base * s.charAt(i-1);
			base = ( a * base ) % 100005;
		}
		return (int)(val % 100005) ;
	}

 	boolean isPrime(long n){
  		if(n==1)return false;
  		if(n<=3)return true;
  		if(n%2==0)return false;
  		for(int i=2 ;i <= Math.sqrt(n); i++){
   			if(n%i==0)return false;
  		}
  		return true;
 	}
 	// sieve
 	int[] sieve(int n){

  		boolean isPrime[] = new boolean[n+1];
  		int p[] = new int[n+1];
  		int idx = 1;
  		// Put above 3 variables globle p[1..idx-1]

  		Arrays.fill(isPrime,true);
  		isPrime[0]=isPrime[1]=false;
  		for(int i = 2 ; i<= n ; i++){
  			if(isPrime[i]){
  				p[idx++] = i;
  				for(int j  = 2* i ; j<= n ; j+=i ){
  					isPrime[j] = false;
  				}

  			}

  		}
  		return p;
 	}
 	long gcd(long a , long b){
  		if(b==0)return a;
  		return gcd(b , a%b);
 	}
 	long lcm(long a , long b){
  		if(a==0||b==0)return 0;
  		return (a*b)/gcd(a,b);
 	}
 	long mulmod(long a , long b ,long mod){
  		if(a==0||b==0)return 0;
  		if(b==1)return a;
   		long ans = mulmod(a,b/2,mod);
   		ans = (ans*2)% mod;
   		if(b%2==1)ans = (a + ans)% mod;
   		return ans;
 	}
 	long pow(long a , long b ,long mod){
   		if(b==0)return 1;
  		if(b==1)return a;
   		long ans = pow(a,b/2,mod);
   		ans = (ans * ans);
   		if(ans >= mod )ans %= mod;

   		if(b%2==1)ans = (a * ans);
   		if(ans >= mod )ans %= mod;

   		return ans;
 	}
 	// 20*20   nCr Pascal Table
 	long[][] ncrTable(){
  		long ncr[][] = new long[21][21];
  		for(int i=0 ;i<=20 ;i++){ncr[i][0]=1;ncr[i][i]=1;}
  		for(int j=0;j<=20 ;j++){
   			for(int i=j+1;i<= 20 ;i++){
    				ncr[i][j] = ncr[i-1][j]+ncr[i-1][j-1];
   			}
  		}
  	return ncr;
 	}
	//*******************************I/O******************************//
	int i()throws Exception{
 		//return Integer.parseInt(br.readLine().trim());
 		return in.nextInt();
	}
	int[] is(int n)throws Exception{
  //int arr[] = new int[n+1];
  		for(int i=1 ; i <= n ;i++)tempints[i] = in.nextInt();
 		return tempints;
	}
	long l()throws Exception{
 		return in.nextLong();
	}
	long[] ls(int n)throws Exception{
 		for(int i=1 ; i <= n ;i++)templongs[i] = in.nextLong();
 		return templongs;
	}

	double d()throws Exception{
 		return in.nextDouble();
	}
	double[] ds(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempdoubles[i] = in.nextDouble();
 		return tempdoubles;
	}
	char c()throws Exception{
 		return in.nextCharacter();
	}
	char[] cs(int n)throws Exception{
  		for(int i=1 ; i <= n ;i++)tempchars[i] = in.nextCharacter();
 		return tempchars;
	}
	String s()throws Exception{
 		return in.nextLine();
	}
	BigInteger bi()throws Exception{
 		return in.nextBigInteger();
	}
//***********************I/O ENDS ***********************//
//*********************** 0.3%f [precision]***********************//
/* roundoff upto 2 digits
   double roundOff = Math.round(a * 100.0) / 100.0;
                    or
   System.out.printf("%.2f", val);

*/
/*
  print upto 2 digits after decimal
  val = ((long)(val * 100.0))/100.0;

*/    private void closeResources(){
		 	 out.flush();
    		 out.close();
    		 return;
	}
	public static void main(String[] args) throws java.lang.Exception{
		//let_me_start Shinch Returns

    /*
    	  // Old Reader Writer
    	  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
	  BufferedReader br=new BufferedReader(new FileReader("input.txt"));
        BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"));
    */
    		 A driver = new A(true);
    		 long start =  System.currentTimeMillis();
    		 driver.run();
    		 long end =  System.currentTimeMillis();
    		 //out.write(" Total Time : "+(end - start)+"\n");
    		 driver.closeResources();
    		 return ;

	}

}

class FastReader{

	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[4*1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public FastReader(InputStream stream){
		this.stream = stream;
	}

	public int read(){
		if (numChars == -1){
			throw new InputMismatchException ();
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				throw new InputMismatchException ();
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar++];
	}

	public int peek(){
		if (numChars == -1){
			return -1;
		}
		if (curChar >= numChars){
			curChar = 0;
			try{
				numChars = stream.read (buf);
			} catch (IOException e){
				return -1;
			}
			if (numChars <= 0){
				return -1;
			}
		}
		return buf[curChar];
	}

	public int nextInt(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		int res = 0;
		do{
			if(c==','){
				c = read();
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public long nextLong(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		long res = 0;
		do{
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		} while (!isSpaceChar (c));
		return res * sgn;
	}

	public String nextString(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		StringBuilder res = new StringBuilder ();
		do{
			res.appendCodePoint (c);
			c = read ();
		} while (!isSpaceChar (c));
		return res.toString ();
	}

	public boolean isSpaceChar(int c){
		if (filter != null){
			return filter.isSpaceChar (c);
		}
		return isWhitespace (c);
	}

	public static boolean isWhitespace(int c){
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private String readLine0(){
		StringBuilder buf = new StringBuilder ();
		int c = read ();
		while (c != '\n' && c != -1){
			if (c != '\r'){
				buf.appendCodePoint (c);
			}
			c = read ();
		}
		return buf.toString ();
	}

	public String nextLine(){
		String s = readLine0 ();
		while (s.trim ().length () == 0)
			s = readLine0 ();
		return s;
	}

	public String nextLine(boolean ignoreEmptyLines){
		if (ignoreEmptyLines){
			return nextLine ();
		}else{
			return readLine0 ();
		}
	}

	public BigInteger nextBigInteger(){
		try{
			return new BigInteger (nextString ());
		} catch (NumberFormatException e){
			throw new InputMismatchException ();
		}
	}

	public char nextCharacter(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		return (char) c;
	}

	public double nextDouble(){
		int c = read ();
		while (isSpaceChar (c))
			c = read ();
		int sgn = 1;
		if (c == '-'){
			sgn = -1;
			c = read ();
		}
		double res = 0;
		while (!isSpaceChar (c) && c != '.'){
			if (c == 'e' || c == 'E'){
				return res * Math.pow (10, nextInt ());
			}
			if (c < '0' || c > '9'){
				throw new InputMismatchException ();
			}
			res *= 10;
			res += c - '0';
			c = read ();
		}
		if (c == '.'){
			c = read ();
			double m = 1;
			while (!isSpaceChar (c)){
				if (c == 'e' || c == 'E'){
					return res * Math.pow (10, nextInt ());
				}
				if (c < '0' || c > '9'){
					throw new InputMismatchException ();
				}
				m /= 10;
				res += (c - '0') * m;
				c = read ();
			}
		}
		return res * sgn;
	}

	public boolean isExhausted(){
		int value;
		while (isSpaceChar (value = peek ()) && value != -1)
			read ();
		return value == -1;
	}

	public String next(){
		return nextString ();
	}

	public SpaceCharFilter getFilter(){
		return filter;
	}

	public void setFilter(SpaceCharFilter filter){
		this.filter = filter;
	}

	public interface SpaceCharFilter{
		public boolean isSpaceChar(int ch);
	}
}
 /******************** Pair class ***********************/

 class Pair implements Comparable<Pair>{
 public int id;
 public int b;
 public int a;
 public int c;
 public Pair(){
  this.id = 1000;

  this.a = 0;
  this.b = 0;
  this.c = 0;
 }
 public Pair(int id , int a,int b , int c ){
  this.id = id;
  this.a = a;
  this.b = b;
  this.c = c;
 }
 public int compareTo(Pair p){
	if(this.a < p.a)return -1;
	else if(this.a > p.a )return 1;
	else {
		if(this.b < p.b)return -1;
		else if(this.b > p.b )return 1;
		else return 0;

	}
 }
 public String toString(){
  return "a="+this.a+" b="+this.b;
 }

}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author root
 */
public class SimpleServer {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();

        int q[][] = new int[n][2];
        int dt[] = new int[n];
        for (int i = 0; i < n; i++) {
            q[i][0] = in.nextInt();
            q[i][1] = in.nextInt();
        }

        Queue<Integer> queue = new LinkedList<>();
        int time = q[0][0] + q[0][1];
        int timex = time;
        dt[0] = time;
        int size = 0;

        for (int i = 1; i < n; i++) {
            if (q[i][0] < time) {
                if(size<b){
                    queue.add(i);
                    size++;
                } else {
                    dt[i] = -1;
                }
            } else {
                while(time<q[i][0]){
                    if(!queue.isEmpty()){
                        int ind = queue.poll();
                        size--;
                        time+=q[ind][1];
                        dt[ind] = time;
                    }
                }
                time+=q[i][1];
                dt[i] = time;
            }
        }

       for(int i = 1;i<n;i++){
           if(dt[i]!=-1){
               if(timex>q[i][0]){
                   timex+=q[i][1];
               } else {
                   timex = q[i][0]+q[i][1];
               }
               dt[i] = timex;
           }

       }

        for (int k = 0; k < dt.length; k++) {
            System.out.print(dt[k] + " ");
        }
        System.out.println("");
    }
}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author root
 */
public class SimpleServer {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();

        int q[][] = new int[n][2];
        long dt[] = new long[n];
        for (int i = 0; i < n; i++) {
            q[i][0] = in.nextInt();
            q[i][1] = in.nextInt();
        }

        Queue<Integer> queue = new LinkedList<>();
        long time = q[0][0] + q[0][1];
        long timex = time;
        dt[0] = time;
        int size = 0;

        for (int i = 1; i < n; i++) {
            if (q[i][0] < time) {
                if(size<b){
                    queue.add(i);
                    size++;
                } else {
                    dt[i] = -1;
                }
            } else {
                while(time<q[i][0]){
                    if(!queue.isEmpty()){
                        int ind = queue.poll();
                        size--;
                        time+=q[ind][1];
                        dt[ind] = time;
                    }
                }
                time+=q[i][1];
                dt[i] = time;
            }
        }

       for(int i = 1;i<n;i++){
           if(dt[i]!=-1){
               if(timex>q[i][0]){
                   timex+=q[i][1];
               } else {
                   timex = q[i][0]+q[i][1];
               }
               dt[i] = timex;
           }
       }

        for (int k = 0; k < dt.length; k++) {
            System.out.print(dt[k] + " ");
        }
        System.out.println("");
    }
}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author root
 */
public class SimpleServer {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int b = in.nextInt();

        int q[][] = new int[n][2];
        long dt[] = new long[n];
        for (int i = 0; i < n; i++) {
            q[i][0] = in.nextInt();
            q[i][1] = in.nextInt();
        }

        Queue<Integer> queue = new LinkedList<>();
        long time = q[0][0] + q[0][1];
        long timex = time;
        dt[0] = time;
        int size = 0;

        for (int i = 1; i < n; i++) {
            if (q[i][0] < time) {
                if (size < b) {
                    queue.add(i);
                    size++;
                } else {
                    dt[i] = -1;
                }
            } else if(time == q[i][0]){
                if(!queue.isEmpty()){
                    int ind = queue.poll();
                    size--;
                    time+=q[ind][1];
                    dt[ind] = time;
                }
                queue.add(i);
                size++;
            }else {
                    while (time < q[i][0]) {
                        if (!queue.isEmpty()) {
                            int ind = queue.poll();
                            size--;
                            time += q[ind][1];
                            dt[ind] = time;
                        } else {
                            time = q[i][0];
                            break;
                        }
                    }
                    queue.add(i);
                    size++;
            }
        }

        for (int i = 1; i < n; i++) {
            if (dt[i] != -1) {
                if (timex > q[i][0]) {
                    timex += q[i][1];
                } else {
                    timex = q[i][0] + q[i][1];
                }
                dt[i] = timex;
            }
        }

        for (int k = 0; k < dt.length; k++) {
            System.out.print(dt[k] + " ");
        }
        System.out.println("");
    }
}


//package croc2016.q;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), lim = ni();
		Deque<Task> q = new ArrayDeque<>();
		long[] ret = new long[n];
		Arrays.fill(ret, -1);
		for(int i = 0;i < n;i++){
			int t = ni(), d = ni();
			while(!q.isEmpty() && q.peekFirst().end <= t){
				q.poll();
			}
			if(q.size() <= lim){
				if(q.isEmpty()){
					ret[i] = (long)t + d;
					q.addLast(new Task(i, ret[i]));
				}else{
					ret[i] = q.peekLast().end + d;
					q.addLast(new Task(i, ret[i]));
				}
			}
		}
		for(int i = 0;i < n;i++){
			out.print(ret[i] + " ");
		}
		out.println();
	}

	static class Task
	{
		int id;
		long end;
		public Task(int id, long end) {
			this.id = id;
			this.end = end;
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new B().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}