import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_CROC2016_Qual {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int b = in.nextInt();
        PriorityQueue<Long> q = new PriorityQueue<>();
        long last = 0;
        for(int i = 0; i < n; i++){
            long v = in.nextInt();
            long d = in.nextInt();
            while(!q.isEmpty() && q.peek() <= v){
                q.poll();
            }
            //System.out.println(q.size() + " " + last);
            if(last <= v){
                out.print((v + d) + " ");
                last = v + d;
            }else if(q.size() < b){
                out.print((last+ d) + " ");
                q.add((last));
                last += d;
            }else{
                out.print((-1) + " ");
            }
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_CROC2016_Qual {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int b = in.nextInt();
        PriorityQueue<Integer> q = new PriorityQueue<>();
        int last = 0;
        for(int i = 0; i < n; i++){
            int v = in.nextInt();
            int d = in.nextInt();
            while(!q.isEmpty() && q.peek() <= v){
                q.poll();
            }
            //System.out.println(q.size() + " " + last);
            if(last <= v){
                out.print((v + d) + " ");
                last += v + d;
            }else if(q.size() < b){
                out.print((last+ d) + " ");
                q.add((last));
                last += d;
            }else{
                out.print((-1) + " ");
            }
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


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

public class B {

    public static void main(String[] args){

        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int b = in.nextInt();

        int[] t = new int[n];
        int[] d = new int[n];
        int[] result = new int[n];

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

        Queue<Integer> decTime = new LinkedList<>();
        Queue<Integer> decReq = new LinkedList<>();
        int lastTime = 0;

        for(int i=0;i<n;++i){
            int tt = t[i];
            while (decTime.peek()!=null&&decTime.peek()<=tt){
                result[decReq.poll()] = decTime.poll();
            }
            if(decTime.size()==0){
                lastTime = tt+d[i];
                decTime.add(lastTime);
                decReq.add(i);
            } else if(decTime.size()<=b){
                lastTime+=d[i];
                decTime.add(lastTime);
                decReq.add(i);
            }else{
                result[i] = -1;
            }
        }

        while (decTime.peek()!=null){
            result[decReq.poll()] = decTime.poll();
        }

        out = new PrintWriter(System.out);
        for(int i=0;i<n;++i){
            out.print(result[i]+" ");
        }
        out.flush();
        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public 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());
        }

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

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

    }
    //--------------------------------------------------------

}


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

public class B {

    public static void main(String[] args){

        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int b = in.nextInt();

        int[] t = new int[n];
        int[] d = new int[n];
        long[] result = new long[n];

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

        Queue<Long> decTime = new LinkedList<>();
        Queue<Integer> decReq = new LinkedList<>();
        long lastTime = 0;

        for(int i=0;i<n;++i){
            int tt = t[i];
            while (decTime.peek()!=null&&decTime.peek()<=tt){
                result[decReq.poll()] = decTime.poll();
            }
            if(decTime.size()==0){
                lastTime = tt+d[i];
                decTime.add(lastTime);
                decReq.add(i);
            } else if(decTime.size()<=b){
                lastTime+=d[i];
                decTime.add(lastTime);
                decReq.add(i);
            }else{
                result[i] = -1;
            }
        }

        while (decTime.peek()!=null){
            result[decReq.poll()] = decTime.poll();
        }

        out = new PrintWriter(System.out);
        for(int i=0;i<n;++i){
            out.print(result[i]+" ");
        }
        out.flush();
        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public 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());
        }

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

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

    }
    //--------------------------------------------------------

}


import java.io.*;
import java.util.Deque;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

    private NotMyScanner in;
    private PrintWriter out;
//    private Timer timer = new Timer();

    static class Server {
        private int mConnectionLimit;
        private Deque<Request> mRequests = new LinkedList<>();

        public Server(int connectionLimit) {
            mConnectionLimit = connectionLimit;
        }

        private void rewind(int time) {
            while (!mRequests.isEmpty() && mRequests.peek().getEndTime() <= time) {
                mRequests.poll();
            }
        }

        public int handle(Request request) {
            rewind(request.getStartTime());
            if (mRequests.size() > mConnectionLimit) {
                return -1;
            }
            if (!mRequests.isEmpty()) {
                request.setEndTime(mRequests.peekLast().getEndTime() + request.getDuration());
            } else {
                request.setEndTime(request.getStartTime() + request.getDuration());
            }
            mRequests.add(request);
            return request.getEndTime();
        }

        static public class Request {
            public int mStartTime;
            public int mDuration;
            public int mEndTime;

            public Request(int startTime, int duration) {
                mStartTime = startTime;
                mDuration = duration;
            }

            public void setEndTime(int endTime) {
                this.mEndTime = endTime;
            }

            public int getStartTime() {
                return mStartTime;
            }

            public int getDuration() {
                return mDuration;
            }

            public int getEndTime() {
                return mEndTime;
            }
        }
    }

    private void solve() throws IOException {
        int n = in.nextInt();
        Server server = new Server(in.nextInt());
        while (n-- > 0) {
            out.print(
                    server.handle(
                            new Server.Request(
                                    in.nextInt(),
                                    in.nextInt()
                            )
                    )
            + " ");
        }
        out.println();
    }

    private void run() throws IOException {
        in = new NotMyScanner();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

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

class NotMyScanner {

    private final BufferedReader br;
    private StringTokenizer st;
    private String last;

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

    public NotMyScanner(String path) throws IOException {
        br = new BufferedReader(new FileReader(path));
    }

    public NotMyScanner(String path, String decoder) throws IOException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), decoder));
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreElements())
            st = new StringTokenizer(br.readLine());
        last = null;
        return st.nextToken();
    }

    String nextLine() throws IOException {
        st = null;
        return (last == null) ? br.readLine() : last;
    }

    boolean hasNext() {
        if (st != null && st.hasMoreElements())
            return true;

        try {
            while (st == null || !st.hasMoreElements()) {
                last = br.readLine();
                st = new StringTokenizer(last);
            }
        } catch (Exception e) {
            return false;
        }

        return true;
    }

    String[] nextStrings(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = next();
        return arr;
    }

    String[] nextLines(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLine();
        return arr;
    }

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

    int[] nextInts(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    Integer[] nextIntegers(int n) throws IOException {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    int[][] next2Ints(int n, int m) throws IOException {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextInt();
        return arr;
    }

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

    long[] nextLongs(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLong();
        return arr;
    }

    long[][] next2Longs(int n, int m) throws IOException {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextLong();
        return arr;
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next().replace(',', '.'));
    }

    double[] nextDoubles(int size) throws IOException {
        double[] arr = new double[size];
        for (int i = 0; i < size; i++)
            arr[i] = nextDouble();
        return arr;
    }

    boolean nextBool() throws IOException {
        String s = next();
        if (s.equalsIgnoreCase("true") || s.equals("1"))
            return true;

        if (s.equalsIgnoreCase("false") || s.equals("0"))
            return false;

        throw new IOException("Boolean expected, String found!");
    }
}


import java.io.*;
import java.util.Deque;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

    private NotMyScanner in;
    private PrintWriter out;
//    private Timer timer = new Timer();

    static class Server {
        private int mConnectionLimit;
        private Deque<Request> mRequests = new LinkedList<>();

        public Server(int connectionLimit) {
            mConnectionLimit = connectionLimit;
        }

        private void rewind(long time) {
            while (!mRequests.isEmpty() && mRequests.peek().getEndTime() <= time) {
                mRequests.poll();
            }
        }

        public long handle(Request request) {
            rewind(request.getStartTime());
            if (mRequests.size() > mConnectionLimit) {
                return -1L;
            }
            if (!mRequests.isEmpty()) {
                request.setEndTime(mRequests.peekLast().getEndTime() + request.getDuration());
            } else {
                request.setEndTime(request.getStartTime() + request.getDuration());
            }
            mRequests.add(request);
            return request.getEndTime();
        }

        static public class Request {
            public long mStartTime;
            public long mDuration;
            public long mEndTime;

            public Request(long startTime, long duration) {
                mStartTime = startTime;
                mDuration = duration;
            }

            public void setEndTime(long endTime) {
                this.mEndTime = endTime;
            }

            public long getStartTime() {
                return mStartTime;
            }

            public long getDuration() {
                return mDuration;
            }

            public long getEndTime() {
                return mEndTime;
            }
        }
    }

    private void solve() throws IOException {
        int n = in.nextInt();
        Server server = new Server(in.nextInt());
        while (n-- > 0) {
            out.print(
                    server.handle(
                            new Server.Request(
                                    in.nextLong(),
                                    in.nextLong()
                            )
                    )
            + " ");
        }
        out.println();
    }

    private void run() throws IOException {
        in = new NotMyScanner();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

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

class NotMyScanner {

    private final BufferedReader br;
    private StringTokenizer st;
    private String last;

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

    public NotMyScanner(String path) throws IOException {
        br = new BufferedReader(new FileReader(path));
    }

    public NotMyScanner(String path, String decoder) throws IOException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), decoder));
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreElements())
            st = new StringTokenizer(br.readLine());
        last = null;
        return st.nextToken();
    }

    String nextLine() throws IOException {
        st = null;
        return (last == null) ? br.readLine() : last;
    }

    boolean hasNext() {
        if (st != null && st.hasMoreElements())
            return true;

        try {
            while (st == null || !st.hasMoreElements()) {
                last = br.readLine();
                st = new StringTokenizer(last);
            }
        } catch (Exception e) {
            return false;
        }

        return true;
    }

    String[] nextStrings(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = next();
        return arr;
    }

    String[] nextLines(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLine();
        return arr;
    }

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

    int[] nextInts(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    Integer[] nextIntegers(int n) throws IOException {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    int[][] next2Ints(int n, int m) throws IOException {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextInt();
        return arr;
    }

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

    long[] nextLongs(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLong();
        return arr;
    }

    long[][] next2Longs(int n, int m) throws IOException {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextLong();
        return arr;
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next().replace(',', '.'));
    }

    double[] nextDoubles(int size) throws IOException {
        double[] arr = new double[size];
        for (int i = 0; i < size; i++)
            arr[i] = nextDouble();
        return arr;
    }

    boolean nextBool() throws IOException {
        String s = next();
        if (s.equalsIgnoreCase("true") || s.equals("1"))
            return true;

        if (s.equalsIgnoreCase("false") || s.equals("0"))
            return false;

        throw new IOException("Boolean expected, String found!");
    }
}


import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int queueMaxSize = input.nextInt() + 1;
        int queue = 0;
        int curTime = 0;
        boolean empty = true;
        int receiveTime[] = new int[n];
        int workTime[] = new int[n];
        int output[] = new int[n];
        TreeMap<Integer, String> alarms = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            receiveTime[i] = input.nextInt();
            workTime[i] = input.nextInt();
            alarms.put(receiveTime[i], "receive");
        }
        int i = 0;
        int lastfree = 0;
        while(i < n) {
            curTime = alarms.ceilingKey(curTime);
            if(alarms.get(curTime).contains("receive") ) {
                if(alarms.get(curTime).contains("free")) {
                    queue--;
                    empty = true;
                }
                if (empty) {
                    if(queue == 0) {
                        lastfree = curTime + workTime[i];
                        if(alarms.containsKey(lastfree))
                            alarms.put(lastfree,alarms.get(lastfree)+"free");
                        else
                            alarms.put(lastfree, "free");
                    }
                    else {
                        lastfree += workTime[i];
                        if(alarms.containsKey(lastfree))
                            alarms.put(lastfree,alarms.get(lastfree)+"free");
                        else
                            alarms.put(lastfree, "free");
                    }
                    queue++;
                    if(queue == queueMaxSize)
                        empty = false;
                    output[i] = lastfree;
                } else {
                    output[i] = -1;
                }
                i++;
            }
            else {
                if(alarms.get(curTime).contains("free")) {
                    queue--;
                    empty = true;
                }
            }
            curTime++;
        }
        for(i = 0; i < n; i++) {
            System.out.print(output[i] + " ");
        }

    }
}


import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int queueMaxSize = input.nextInt() + 1;
        int queue = 0;
        long curTime = 0;
        boolean empty = true;
        int workTime[] = new int[n];
        long output[] = new long[n];
        TreeMap<Long, String> alarms = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            alarms.put(input.nextLong(), "receive");
            workTime[i] = input.nextInt();
        }
        int i = 0;
        long lastfree = 0;
        while(i < n) {
            curTime = alarms.ceilingKey(curTime);
            if(alarms.get(curTime).contains("receive") ) {
                if(alarms.get(curTime).contains("free")) {
                    queue--;
                    empty = true;
                }
                if (empty) {
                    if(queue == 0) {
                        lastfree = curTime + workTime[i];
                        alarms.put(lastfree, alarms.getOrDefault(lastfree, "")+"free");
                    }
                    else {
                        lastfree += workTime[i];
                        alarms.put(lastfree, alarms.getOrDefault(lastfree, "")+"free");
                    }
                    queue++;
                    if(queue == queueMaxSize)
                        empty = false;
                    output[i] = lastfree;
                } else {
                    output[i] = -1;
                }
                i++;
            }
            else {
                if(alarms.get(curTime).contains("free")) {
                    queue--;
                    empty = true;
                }
            }
            curTime++;
        }
        for(i = 0; i < n; i++) {
            System.out.print(output[i] + " ");
        }

    }
}


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

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

        long[] a = new long[200000];
        Queue<Long> queue = new LinkedList<Long>();
        long res = 0;

        for (int i = 0; i < N; i++) {
            long ti = scanner.nextInt();
            long di = scanner.nextInt();
            while (!queue.isEmpty() && queue.element() <= ti) queue.remove();
            if(queue.isEmpty()) res = ti;
            if(queue.size() <= b) {
                res = res + di;
                a[i] = res;
                queue.add(res);
            } else a[i] = -1;
        }

        for (int i = 0; i < N; i++) {
            System.out.print(a[i]+" ");
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * Created by pallavi on 16/3/16.
 */
public class B644 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        LinkedList<Integer> queue = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            tokenizer = new StringTokenizer(reader.readLine());
            int t = Integer.parseInt(tokenizer.nextToken());
            int d = Integer.parseInt(tokenizer.nextToken());
            while (!queue.isEmpty() && queue.getFirst() <= t) {
                queue.pollFirst();
            }
            if (queue.size() == b+1) {
                System.out.print("-1 ");
            } else {
                if (queue.isEmpty()) {
                    queue.add(t+d);
                    System.out.print((t + d) + " ");
                } else {
                    System.out.print((queue.getLast()+d) + " ");
                    queue.add(queue.getLast()+d);
                }
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * Created by pallavi on 16/3/16.
 */
public class B644 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        LinkedList<Long> queue = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            tokenizer = new StringTokenizer(reader.readLine());
            long t = Long.parseLong(tokenizer.nextToken());
            long d = Long.parseLong(tokenizer.nextToken());
            while (!queue.isEmpty() && queue.getFirst() <= t) {
                queue.pollFirst();
            }
            if (queue.size() == b+1) {
                System.out.print("-1 ");
            } else {
                if (queue.isEmpty()) {
                    queue.add(t+d);
                    System.out.print((t + d) + " ");
                } else {
                    System.out.print((queue.getLast()+d) + " ");
                    queue.add(queue.getLast()+d);
                }
            }
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Feng Jiajie
 */
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(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.readInt();
      int b = in.readInt();
      int[] t = new int[n];
      int[] d = new int[n];
      for (int i = 0; i < n; i++) {
        t[i] = in.readInt();
        d[i] = in.readInt();
      }
      Queue<Integer> queue = new ArrayDeque<>();
      int i = 0;
      int nowTime = -1;
      int bb = b + 1;
      int[] ans = new int[n];
      while (i < n) {
        while (queue.size() < bb) {
          queue.add(i);
          i++;
        }

        int x = queue.peek();
        int xTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = xTime;
        queue.poll();

        while (i < n && !queue.isEmpty()) {
          if (t[i] < xTime) {
            ans[i] = -1;
            ++i;
          } else {
            queue.add(i);
            ++i;
            break;
          }

        }
        nowTime = xTime;
      }

      while (!queue.isEmpty()) {
        int x = queue.poll();
        int xTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = xTime;
        nowTime = xTime;
      }

      for (int j = 0; j < n; j++) {
        if (j != 0) {
          out.print(" ");
        }
        out.print(ans[j]);
      }
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

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

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0)
          writer.print(' ');
        writer.print(objects[i]);
      }
    }

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

    public void print(int i) {
      writer.print(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(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 readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int 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 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;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Feng Jiajie
 */
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(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.readInt();
      int b = in.readInt();
      long[] t = new long[n];
      long[] d = new long[n];
      for (int i = 0; i < n; i++) {
        t[i] = in.readInt();
        d[i] = in.readInt();
      }
      Queue<Integer> queue = new ArrayDeque<>();
      int i = 0;
      long nowTime = -1;
      int bb = b + 1;
      long[] ans = new long[n];
      while (i < n) {
        while (queue.size() < bb && i < n) {
          queue.add(i);
          i++;
        }

        int x = queue.peek();
        long xTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = xTime;
        queue.poll();

        while (i < n && t[i] < xTime) {
          ans[i] = -1;
          ++i;
        }
        nowTime = xTime;
      }

      while (!queue.isEmpty()) {
        int x = queue.poll();
        nowTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = nowTime;
      }

      for (int j = 0; j < n; j++) {
        if (j != 0) {
          out.print(" ");
        }
        out.print(ans[j]);
      }
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

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

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0)
          writer.print(' ');
        writer.print(objects[i]);
      }
    }

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

    public void print(long i) {
      writer.print(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(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 readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int 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 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;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Feng Jiajie
 */
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(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.readInt();
      int b = in.readInt();
      int[] t = new int[n];
      int[] d = new int[n];
      for (int i = 0; i < n; i++) {
        t[i] = in.readInt();
        d[i] = in.readInt();
      }
      Queue<Integer> queue = new ArrayDeque<>();
      int i = 0;
      int nowTime = -1;
      int bb = b + 1;
      int[] ans = new int[n];
      while (i < n) {
        while (queue.size() < bb && i < n) {
          queue.add(i);
          i++;
        }

        int x = queue.peek();
        int xTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = xTime;
        queue.poll();

        while (i < n && !queue.isEmpty()) {
          if (t[i] < xTime) {
            ans[i] = -1;
            ++i;
          } else {
            queue.add(i);
            ++i;
            break;
          }
        }
        nowTime = xTime;
      }

      while (!queue.isEmpty()) {
        int x = queue.poll();
        int xTime = Math.max(nowTime, t[x]) + d[x];
        ans[x] = xTime;
        nowTime = xTime;
      }

      for (int j = 0; j < n; j++) {
        if (j != 0) {
          out.print(" ");
        }
        out.print(ans[j]);
      }
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

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

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
      for (int i = 0; i < objects.length; i++) {
        if (i != 0)
          writer.print(' ');
        writer.print(objects[i]);
      }
    }

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

    public void print(int i) {
      writer.print(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(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 readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int 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 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;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }
}


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

/**
 * Created by wannabe on 17.03.16.
 */
public class B {

	public static class Request implements Comparable<Request> {

		private final Integer time;
		private final Integer duration;
		private final Integer position;

		public Request(Integer time, Integer duration, Integer position) {
			this.duration = duration;
			this.time = time;
			this.position = position;
		}

		public Integer getTime() {
			return time;
		}

		public Integer getDuration() {
			return duration;
		}

		public Integer getPosition() {
			return position;
		}

		@Override
		public int compareTo(Request o) {
			return time.compareTo(o.getTime());
		}
	}

	public static void writeData(String data) throws IOException {
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		log.write(data);
		log.flush();
	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);

			int position, time;
			Request[] requests = new Request[n];
			Deque<Request> requestsIncoming = new ArrayDeque<>(n);
			for (int i = 0; i < n; i++) {
				line = br.readLine().split(" ");
				position = Integer.parseInt(line[0]);
				time = Integer.parseInt(line[1]);
				requests[i] =new Request(position, time, i);
			}
			Arrays.sort(requests);
			for (int i = 0; i < n; i++) {
				requestsIncoming.addFirst(requests[i]);
			}

			String[] processedRequests = new String[n];

			long currentTime = requestsIncoming.peekLast().getTime();
			long dequeDuration = 0;
			Deque<Request> deque = new ArrayDeque<>(n);
			while (requestsIncoming.size() > 0) {
				Request request = requestsIncoming.removeLast();
				if (currentTime > request.getTime()) {
					while (deque.size() > 0 && request.getTime() >= currentTime - dequeDuration) {
						dequeDuration -= deque.removeLast().getDuration();
					}
					if (deque.size() >= b) {
						processedRequests[request.getPosition()] = "-1";
						continue;
					} else {
						dequeDuration += request.getDuration();
						deque.addFirst(request);
					}
				} else {
					currentTime += request.getTime() - currentTime;
				}
				currentTime += request.getDuration();
				processedRequests[request.getPosition()] = String.valueOf(currentTime);
			}
			writeData(String.join(" ", processedRequests));
		}
	}
}


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

/**
 * Created by wannabe on 17.03.16.
 */
public class C {

	public static class Request implements Comparable<Request> {

		private final Integer time;
		private final Integer duration;
		private final Integer position;

		public Request(Integer time, Integer duration, Integer position) {
			this.duration = duration;
			this.time = time;
			this.position = position;
		}

		public Integer getTime() {
			return time;
		}

		public Integer getDuration() {
			return duration;
		}

		public Integer getPosition() {
			return position;
		}

		@Override
		public int compareTo(Request o) {
			return time.compareTo(o.getTime());
		}
	}

	public static void writeData(String data) throws IOException {
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		log.write(data);
		log.flush();
	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);

			int position, time;
			Request[] requests = new Request[n];
			Deque<Request> requestsIncoming = new ArrayDeque<>(n);
			for (int i = 0; i < n; i++) {
				line = br.readLine().split(" ");
				position = Integer.parseInt(line[0]);
				time = Integer.parseInt(line[1]);
				requests[i] =new Request(position, time, i);
			}
			Arrays.sort(requests);
			for (int i = 0; i < n; i++) {
				requestsIncoming.addFirst(requests[i]);
			}

			Request firstRequest = requestsIncoming.removeLast();
			Request currentRequest = firstRequest;
			int currentTime = firstRequest.getTime();
			int currentRequestProcessingTime = firstRequest.getDuration();
			String[] processedRequests = new String[n];
			Deque<Request> queue = new ArrayDeque<>(n);

			while (true) {

				currentTime++;
				if (currentRequestProcessingTime > 0) {
					currentRequestProcessingTime--;
				}
				if (currentRequestProcessingTime == 0) {
					if (currentRequest != null) {
						processedRequests[currentRequest.getPosition()] = String.valueOf(currentTime);
						currentRequest = null;
					}
					if (queue.size() == 0 && requestsIncoming.size() == 0) {
						writeData(String.join(" ", processedRequests));
						return;
					}
					if (queue.size() > 0) {
						currentRequest = queue.removeLast();
						currentRequestProcessingTime = currentRequest.getDuration();
					}
				}

				if (requestsIncoming.size() > 0) {
					if (requestsIncoming.getLast().getTime() == currentTime) {
						if (queue.size() == b) {
							processedRequests[requestsIncoming.removeLast().getPosition()] = "-1";
						} else {
							queue.addFirst(requestsIncoming.removeLast());
						}
					}
				}

			}

		}
	}
}


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

/**
 * Created by wannabe on 17.03.16.
 */
public class C {

	public static class Request implements Comparable<Request> {

		private final Integer time;
		private final Integer duration;
		private final Integer position;

		public Request(Integer time, Integer duration, Integer position) {
			this.duration = duration;
			this.time = time;
			this.position = position;
		}

		public Integer getTime() {
			return time;
		}

		public Integer getDuration() {
			return duration;
		}

		public Integer getPosition() {
			return position;
		}

		@Override
		public int compareTo(Request o) {
			return time.compareTo(o.getTime());
		}
	}

	public static void writeData(String data) throws IOException {
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		log.write(data);
		log.flush();
	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);

			int position, time;
			Request[] requests = new Request[n];
			Deque<Request> requestsIncoming = new ArrayDeque<>(n);
			for (int i = 0; i < n; i++) {
				line = br.readLine().split(" ");
				position = Integer.parseInt(line[0]);
				time = Integer.parseInt(line[1]);
				requests[i] =new Request(position, time, i);
			}
			Arrays.sort(requests);
			for (int i = 0; i < n; i++) {
				requestsIncoming.addFirst(requests[i]);
			}

			String[] processedRequests = new String[n];

			long currentTime = requestsIncoming.peekLast().getTime();
			long dequeDuration = 0;
			Deque<Request> deque = new ArrayDeque<>(n);
			while (requestsIncoming.size() > 0) {
				Request request = requestsIncoming.removeLast();
				if (currentTime > request.getTime()) {
					while (deque.size() > 0 && request.getTime() >= currentTime - dequeDuration) {
						dequeDuration -= deque.removeLast().getDuration();
					}
					if (deque.size() >= b) {
						processedRequests[request.getPosition()] = "-1";
						continue;
					} else {
						dequeDuration += request.getDuration();
						deque.addFirst(request);
					}
				}
				currentTime += request.getDuration();
				processedRequests[request.getPosition()] = String.valueOf(currentTime);
			}
			writeData(String.join(" ", processedRequests));
		}
	}
}


import java.math.BigInteger;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        IO io ;
        try {
            io = new IO("in.in", null);
        } catch (IOException e) {
            io = new IO(null, null);
        }
        int n = io.getNextInt(),b = io.getNextInt();
        int [] T = new int[n];
        int [] D = new int[n];
        for (int i = 0;i < n;i++) {
            T[i] = io.getNextInt();
            D[i] = io.getNextInt();
        }
        Queue<Integer> q = new LinkedList<>();
        long [] ans = new long[n];
        for (int i = 0;i < n;i++) ans[i] = -1;
        long ct = 0;
        for (int i = 0;i < n || !q.isEmpty();) {
            while (i < n && T[i] < ct) {
                if (q.size() < b) q.add(i);
                i++;
            }
            int j = -1;
            if (i < n) j = i;
            if (!q.isEmpty())
                j = q.poll();
            ct = Math.max(ct,T[j] + 0L);
            if (j != -1)
                ans[j] = ct += D[j];
            if (j == i)
                i++;
        }
        for (int i = 0;i < n;i++){
            io.print(ans[i]);
            if (i == n-1) io.println("");
            else io.print(" ");
        }
        io.close();
    }
    private static final int onebillion7 = 1000000007;
}

class pair{
    int val,type;
    public pair(int v,int t) {
        val = v;
        type = t;
    }
    @Override
    public String toString(){
        return "(" + val + ", " + type + ")";
    }
}

class Buffer{
    ArrayList<Character> AS;
    public Buffer(){
        AS = new ArrayList<>();
    }
    public void append(String s){
        for (char c : s.toCharArray())
            AS.add(c);
    }
    public void appendLine(String s) {
        append(s);
        AS.add('\n');
    }
    public void clear(){
        AS.clear();
    }
    public String toString(){
        StringBuilder sb = new StringBuilder();
        for (char c : AS)
            sb.append(c);
        return sb.toString();
    }
}

class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}

//class PollardRho {
//    private final static BigInteger ZERO = new BigInteger("0");
//    private final static BigInteger ONE  = new BigInteger("1");
//    private final static BigInteger TWO  = new BigInteger("2");
//    private final static SecureRandom random = new SecureRandom();
//    private static ArrayList<Long> primes = new ArrayList<>();
//
//    private static BigInteger rho(BigInteger N) {
//        BigInteger divisor;
//        BigInteger c  = new BigInteger(N.bitLength(), random);
//        BigInteger x  = new BigInteger(N.bitLength(), random);
//        BigInteger xx = x;
//
//        // check divisibility by 2
//        if (N.base(TWO).compareTo(ZERO) == 0) return TWO;
//
//        do {
//            x  =  x.multiply(x).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            divisor = x.subtract(xx).gcd(N);
//        } while((divisor.compareTo(ONE)) == 0);
//
//        return divisor;
//    }
//
//    private static void factor(BigInteger N) {
//        if (N.compareTo(ONE) == 0) return;
//        if (N.isProbablePrime(20)) {
//            primes.add(N.longValue());
//            return;
//        }
//        BigInteger divisor = rho(N);
//        factor(divisor);
//        factor(N.divide(divisor));
//    }
//
//
//    public static ArrayList<Long> factor(Long n) {
//        primes.clear();
//        factor(BigInteger.valueOf(n));
//        return primes;
//    }
//}


import java.math.BigInteger;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        IO io ;
        try {
            io = new IO("in.in", null);
        } catch (IOException e) {
            io = new IO(null, null);
        }
        int n = io.getNextInt(),b = io.getNextInt();
        int [] T = new int[n];
        int [] D = new int[n];
        for (int i = 0;i < n;i++) {
            T[i] = io.getNextInt();
            D[i] = io.getNextInt();
        }
        Queue<Integer> q = new LinkedList<>();
        long [] ans = new long[n];
        for (int i = 0;i < n;i++) ans[i] = -1;
        long ct = 0;
        for (int i = 0;i < n;) {
            while (i < n && T[i] < ct) {
                if (q.size() < b) q.add(i);
                i++;
            }
            int j = -1;
            if (i < n) j = i;
            if (!q.isEmpty())
                j = q.poll();
            ct = Math.max(ct,T[j] + 0L);
            if (j != -1)
                ans[j] = ct += D[j];
            if (j == i)
                i++;
        }
        for (int i = 0;i < n;i++){
            io.print(ans[i]);
            if (i == n-1) io.println("");
            else io.print(" ");
        }
        io.close();
    }
    private static final int onebillion7 = 1000000007;
}

class pair{
    int val,type;
    public pair(int v,int t) {
        val = v;
        type = t;
    }
    @Override
    public String toString(){
        return "(" + val + ", " + type + ")";
    }
}

class Buffer{
    ArrayList<Character> AS;
    public Buffer(){
        AS = new ArrayList<>();
    }
    public void append(String s){
        for (char c : s.toCharArray())
            AS.add(c);
    }
    public void appendLine(String s) {
        append(s);
        AS.add('\n');
    }
    public void clear(){
        AS.clear();
    }
    public String toString(){
        StringBuilder sb = new StringBuilder();
        for (char c : AS)
            sb.append(c);
        return sb.toString();
    }
}

class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}

//class PollardRho {
//    private final static BigInteger ZERO = new BigInteger("0");
//    private final static BigInteger ONE  = new BigInteger("1");
//    private final static BigInteger TWO  = new BigInteger("2");
//    private final static SecureRandom random = new SecureRandom();
//    private static ArrayList<Long> primes = new ArrayList<>();
//
//    private static BigInteger rho(BigInteger N) {
//        BigInteger divisor;
//        BigInteger c  = new BigInteger(N.bitLength(), random);
//        BigInteger x  = new BigInteger(N.bitLength(), random);
//        BigInteger xx = x;
//
//        // check divisibility by 2
//        if (N.base(TWO).compareTo(ZERO) == 0) return TWO;
//
//        do {
//            x  =  x.multiply(x).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            divisor = x.subtract(xx).gcd(N);
//        } while((divisor.compareTo(ONE)) == 0);
//
//        return divisor;
//    }
//
//    private static void factor(BigInteger N) {
//        if (N.compareTo(ONE) == 0) return;
//        if (N.isProbablePrime(20)) {
//            primes.add(N.longValue());
//            return;
//        }
//        BigInteger divisor = rho(N);
//        factor(divisor);
//        factor(N.divide(divisor));
//    }
//
//
//    public static ArrayList<Long> factor(Long n) {
//        primes.clear();
//        factor(BigInteger.valueOf(n));
//        return primes;
//    }
//}


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

public class Main {
    public 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());
        }

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

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

    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int n = sc.nextInt(), b = sc.nextInt();
        int t[] = new int[n];
        int d[] = new int[n];
        for(int i = 0; i < n; ++i) {
            t[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        long ans[] = new long[n];
        for(int i = 0; i < n; ++i)
            ans[i] = -1;
        long cur = 0;
        Queue<Integer> q = new LinkedList<>();

        for(int i = 0; i < n; ++i) {
            while (t[i] >= cur && !q.isEmpty()) {
                int j = q.poll();
                cur += d[j];
                ans[j] = cur;
            }
            if (cur < t[i]) {
                cur = t[i]+d[i];
                ans[i] = cur;
            } else if (q.size() < b)
                q.add(i);
        }
        while (!q.isEmpty()) {
            cur += d[q.peek()];
            ans[q.poll()] = cur;
        }

        PrintWriter pw = new PrintWriter(System.out);
        for(int i = 0; i < n; ++i)
            pw.print(ans[i] + " ");
        pw.close();
    }
}


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Queue<Long> q = new LinkedList<Long> ();
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long b = sc.nextLong();
        long process_time = 0;
        for(int i = 0 ; i < n ; i ++){
            long t = sc.nextLong();
            long d = sc.nextLong();
            while (q.size() > 0 && q.element()<=t){
                q.remove();
            }
            if(q.size() <= b){
                if (process_time < t)
                process_time = t;
                process_time = process_time + d; // calculate the time to complete task t_i
                System.out.printf("%d ", process_time);
                q.offer(process_time);
            }
            else
                System.out.print("-1 ");
        }
    }
}


import java.io.*;
import java.util.*;
public class Main {

    public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] a = new String[3];
        for (int i = 0; i < 3; i++) {
            a[i] = Convert(br.readLine());
        }

        String[] q = {
                a[0] + a[1] + a[2],
                a[0] + a[2] + a[1],
                a[1] + a[0] + a[2],
                a[1] + a[2] + a[0],
                a[2] + a[0] + a[1],
                a[2] + a[1] + a[0]
        };
        StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
        for (int i = 0; i < n; i++) {
            String s = Convert(br.readLine());
            boolean flag = false;
            for (int j = 0; j < 6; j++) {
                if (s.equals(q[j])) {
                	flag = true;
                	break;
                }
            }
            if(flag){
            	System.out.println("ACC");
            }
            else{
            	System.out.println("WA");
            }

        }
	}
    public static String Convert(String s) {
	    StringBuilder sb = new StringBuilder();
	    for (int i = 0; i < s.length(); i++) {
	        char c = s.charAt(i);
	        if (c == '_' || c == ';' || c == '-') {

	        } else {
	            sb.append(c);
	        }
	    }
	    return sb.toString().toLowerCase();
	}
}


import java.io.*;
import java.util.*;
/**
 *
 * @author Tuan Kyou
 */
public class _644_B {

    public static void main(String[] args) throws IOException {
		Deque<Long> q = new LinkedList<Long> ();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long n = Long.parseLong(st.nextToken());
        long b = Long.parseLong(st.nextToken());
        for(int i = 0 ; i < n ; i ++){
        	st = new StringTokenizer(br.readLine());
	        long t = Long.parseLong(st.nextToken());
	        long d = Long.parseLong(st.nextToken());
	        while (q.size() > 0 && q.element()<=t){
	        	q.remove();
	        }
	        if(q.size() <= b){
	        	if(q.size()>0){
	        		t = q.getLast();
	        	}
	        	t+=d;
	        	System.out.print(t + " ");
	        	q.add(t);
	        }
	        else
	        	System.out.print("-1 ");
        }

	}

}


import java.io.*;
import java.util.*;

public class B{
    public static void main(String[] argin) {
        B inst = new B();
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt(), b=in.nextInt();
            Deque<int[]> q = new ArrayDeque<int[]>();
            long[] ret = new long[n];
            long t=0;
            for(int i=0; i<n; i++){
                int ti=in.nextInt(), di=in.nextInt();
                while(t<=ti && !q.isEmpty()){
                    int[] qx = q.pollFirst();
                    if(t<qx[0])
                        t=qx[0]+qx[1];
                    else
                        t+=qx[1];
                    ret[qx[2]]=t;
                }
                if(q.size()<b)
                    q.offerLast(new int[]{ti,di,i});
                else
                    ret[i]=-1;
            }
            while(!q.isEmpty()){
                int[] qx = q.pollFirst();
                if(t<qx[0])
                    t=qx[0]+qx[1];
                else
                    t+=qx[1];
                ret[qx[2]]=t;
            }
            for(int y : ret)
                System.out.print(y+" ");
            System.out.println();
        }
    }
}


import java.io.*;
import java.util.*;

public class B{
    public static void main(String[] argin) {
        B inst = new B();
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt(), b=in.nextInt();
            Deque<int[]> q = new ArrayDeque<int[]>();
            long[] ret = new long[n];
            long t=0;
            for(int i=0; i<n; i++){
                int ti=in.nextInt(), di=in.nextInt();
                while(t<=ti && !q.isEmpty()){
                    int[] qx = q.pollFirst();
                    if(t<qx[0])
                        t=qx[0]+qx[1];
                    else
                        t+=qx[1];
                    ret[qx[2]]=t;
                }
                if(q.size()<b)
                    q.offerLast(new int[]{ti,di,i});
                else
                    ret[i]=-1;
            }
            while(!q.isEmpty()){
                int[] qx = q.pollFirst();
                if(t<qx[0])
                    t=qx[0]+qx[1];
                else
                    t+=qx[1];
                ret[qx[2]]=t;
            }
            for(long y : ret)
                System.out.print(y+" ");
            System.out.println();
        }
    }
}


import java.io.*;
import java.util.*;

public class B{
    public static void main(String[] argin) {
        B inst = new B();
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt(), b=in.nextInt();
            Deque<int[]> q = new ArrayDeque<int[]>();
            int[] ret = new int[n];
            int t=0;
            for(int i=0; i<n; i++){
                int ti=in.nextInt(), di=in.nextInt();
                while(t<=ti && !q.isEmpty()){
                    int[] qx = q.pollFirst();
                    if(t<qx[0])
                        t=qx[0]+qx[1];
                    else
                        t+=qx[1];
                    ret[qx[2]]=t;
                }
                if(q.size()<b)
                    q.offerLast(new int[]{ti,di,i});
                else
                    ret[i]=-1;
            }
            while(!q.isEmpty()){
                int[] qx = q.pollFirst();
                if(t<qx[0])
                    t=qx[0]+qx[1];
                else
                    t+=qx[1];
                ret[qx[2]]=t;
            }
            for(int y : ret)
                System.out.print(y+" ");
            System.out.println();
        }
    }
}


import java.util.*;
import java.io.*;

public class B {
    FastScanner in;
    PrintWriter out;

    class Event {
        int t, d;

        public Event(int t, int d) {
            this.t = t;
            this.d = d;
        }
    }

    public void solve() throws IOException {
        int n = in.nextInt();
        int b = in.nextInt();
        Event[] a = new Event[n];
        Arrays.setAll(a, i -> new Event(in.nextInt(), in.nextInt()));
        boolean[] need = new boolean[n];
        Arrays.fill(need, true);
        int next = 0;
        int inQ = 0;
        int time = 0;
        for (int i = 0; i < n; i++) {
            if (need[i]) {
                if (i == next) next++;
                if (time > a[i].t) time += a[i].d;
                else time = a[i].t + a[i].d;
                while (next < n && a[next].t < time) {
                    if (inQ == b) {
                        need[next] = false;
                    } else {
                        inQ++;
                    }
                    next++;
                }
                inQ--;
                out.print(time + " ");
            } else {
                out.print(-1 + " ");
            }
        }
        out.println();
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

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

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


import java.util.*;
import java.io.*;

public class B {
    FastScanner in;
    PrintWriter out;

    class Event {
        long t, d;

        public Event(int t, int d) {
            this.t = t;
            this.d = d;
        }
    }
    /*
    .......
    .......
    .......
    .......
     */

    public void solve() throws IOException {
        int n = in.nextInt();
        long b = in.nextInt();
        Event[] a = new Event[n];
        Arrays.setAll(a, i -> new Event(in.nextInt(), in.nextInt()));
        boolean[] need = new boolean[n];
        Arrays.fill(need, true);
        int next = 0;
        int inQ = 0;
        long time = 0;
        for (int i = 0; i < n; i++) {
            if (need[i]) {
                if (i == next) next++;
                if (time > a[i].t) time += a[i].d;
                else time = a[i].t + a[i].d;
                while (next < n && a[next].t < time) {
                    if (inQ == b) {
                        need[next] = false;
                    } else {
                        inQ++;
                    }
                    next++;
                }
                if (inQ > 0) inQ--;
                out.print(time + " ");
            } else {
                out.print(-1 + " ");
            }
        }
        out.println();
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

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

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


import java.util.*;
import java.io.*;

public class B {
    FastScanner in;
    PrintWriter out;

    class Event {
        long t, d;

        public Event(int t, int d) {
            this.t = t;
            this.d = d;
        }
    }

    public void solve() throws IOException {
        int n = in.nextInt();
        long b = in.nextInt();
        Event[] a = new Event[n];
        Arrays.setAll(a, i -> new Event(in.nextInt(), in.nextInt()));
        boolean[] need = new boolean[n];
        Arrays.fill(need, true);
        int next = 0;
        int inQ = 0;
        long time = 0;
        for (int i = 0; i < n; i++) {
            if (need[i]) {
                if (i == next) next++;
                if (time > a[i].t) time += a[i].d;
                else time = a[i].t + a[i].d;
                while (next < n && a[next].t < time) {
                    if (inQ == b) {
                        need[next] = false;
                    } else {
                        inQ++;
                    }
                    next++;
                }
                inQ--;
                out.print(time + " ");
            } else {
                out.print(-1 + " ");
            }
        }
        out.println();
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

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

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


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    private static StreamTokenizer in;
    private static Scanner ins;
    private static PrintWriter out;

    public static void main(String[] args) {

        try {
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            ins = new Scanner(System.in);
            out = new PrintWriter(System.out);
            try {
                if (System.getProperty("xDx") != null) {
                    in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt")));
                    ins = new Scanner(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                }
            } catch (Exception e) {
                in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
                ins = new Scanner(System.in);
                out = new PrintWriter(System.out);
            }
            new Main().run();
            out.close();
        } catch (Throwable e) {
//            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    private int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    private long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

    private double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    private String nextString() throws IOException {
        in.nextToken();
        return in.sval;
    }

    private char nextChar() throws IOException {
        in.nextToken();
        return (char) in.ttype;
    }

    private void run() throws Exception {
        int n = nextInt();
        long[] answ = new long[n];
        int b = nextInt();
        long curTime = 0;
        boolean working = false;
        long finishTime = 0;
        Queue<Pair> taskQueue = new ArrayDeque<>();
        for(int i = 0; i < n; i++) {
            long t = nextInt();
            long d = nextInt();
            while (working && finishTime <= t) {
                curTime = finishTime;
                if(!taskQueue.isEmpty()) {
                    Pair pair = taskQueue.poll();
                    finishTime = curTime + pair.len;
                    answ[pair.index] = finishTime;
                } else {
                    working = false;
                }
            }

            curTime = t;

            if(working){
                if(taskQueue.size() < b) {
                    taskQueue.add(new Pair(i, d));
                } else {
                    answ[i] = -1;
                }
            } else {
                working = true;
                finishTime = curTime + d;
                answ[i] = finishTime;
            }
        }

        while (!taskQueue.isEmpty()) {
            curTime = finishTime;

            Pair pair = taskQueue.poll();
            finishTime = curTime + pair.len;
            answ[pair.index] = finishTime;
        }

        Arrays.stream(answ).forEach(time -> out.print(time + " "));
    }

    private class Pair{
        int index;
        long len;

        public Pair(int index, long len) {
            this.index = index;
            this.len = len;
        }
    }

    private int gcd(int a, int b) {
        while (a > 0 && b > 0) {
            int k = a % b;
            a = b;
            b = k;
        }

        return a | b;
    }

}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
    http://codeforces.com/contest/644/problem/B

    Input
    The first line of the input contains two integers n and b (1 ≤ n, b ≤ 200 000) — the number of queries and the
    maximum possible size of the query queue.

    Then follow n lines with queries descriptions (in chronological order). Each description consists of two integers
    ti and di (1 ≤ ti, di ≤ 10^9), where ti is the moment of time when the i-th query appears and di is the time server
    needs to process it. It guaranteed that ti - 1 < ti for all i > 1.

    Output
    Print the sequence of n integers e1, e2, ..., en, where ei is the moment the server will finish to process the i-th
    query (queries are numbered in the order they appear in the input) or  - 1 if the corresponding query will be rejected.
*/

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = in.nextInt(); // number or queries
        int b = in.nextInt() + 1; // query queue size

        long [] queue = new long[b];
        int ptrFirst = 0;
        int querysNum = 0;

        for (int i = 0; i < n; i++) {
            int t = in.nextInt(); // time query appear
            int d = in.nextInt(); // time server needs to process
            // process queue
            while(querysNum > 0 && t >= queue[ptrFirst%b]){
                ptrFirst++;
                querysNum--;
            }

            // try to add query to queue
            if(querysNum == b){
                // queue is full
                out.print(" -1"); // reject query
            } else {
                long processTime = Math.max(queue[ptrFirst%b]+d,t+d);
                queue[(ptrFirst+querysNum)%b] = processTime;
                querysNum++;
                out.printf(" %d",processTime); // print query process time
            }

        }

        in.close();
        out.close();
    }

}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
    http://codeforces.com/contest/644/problem/B

    Input
    The first line of the input contains two integers n and b (1 ≤ n, b ≤ 200 000) — the number of queries and the
    maximum possible size of the query queue.

    Then follow n lines with queries descriptions (in chronological order). Each description consists of two integers
    ti and di (1 ≤ ti, di ≤ 10^9), where ti is the moment of time when the i-th query appears and di is the time server
    needs to process it. It guaranteed that ti - 1 < ti for all i > 1.

    Output
    Print the sequence of n integers e1, e2, ..., en, where ei is the moment the server will finish to process the i-th
    query (queries are numbered in the order they appear in the input) or  - 1 if the corresponding query will be rejected.
*/

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = in.nextInt(); // number or queries
        int b = in.nextInt() + 1; // query queue size

        long [] queue = new long[b];
        int ptrFirst = 0;
        int querysNum = 0;

        for (int i = 0; i < n; i++) {
            int t = in.nextInt(); // time query appear
            int d = in.nextInt(); // time server needs to process
            // process queue
            while(querysNum > 0 && t >= queue[ptrFirst%b]){
                ptrFirst++;
                querysNum--;
            }

            // try to add query to queue
            if(querysNum == b){
                // queue is full
                out.print(" -1"); // reject query
            } else {
                long processTime;
                if(querysNum>0){
                    processTime = queue[(ptrFirst+querysNum-1)%b]+d;
                } else {
                    processTime = t+d;
                }
                queue[(ptrFirst+querysNum)%b] = processTime;
                querysNum++;
                out.printf(" %d",processTime); // print query process time
            }

        }

        in.close();
        out.close();
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artyom Korzun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static
    @SuppressWarnings("Duplicates")
    class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int b = in.nextInt();

            ArrayDeque<Long> q = new ArrayDeque<>(b);
            for (int i = 0; i < n; i++) {
                int t = in.nextInt();
                int d = in.nextInt();

                while (!q.isEmpty() && q.peekFirst() <= t)
                    q.pollFirst();

                long end = -1;
                if (q.size() <= b) {
                    end = (q.isEmpty() ? t : q.peekLast()) + d;
                    q.add(end);
                }

                out.print(end + " ");
            }

        }

    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(nextLine());

            return tokenizer.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artyom Korzun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int b = in.nextInt();

            ArrayDeque<Integer> q = new ArrayDeque<>(b);
            for (int i = 0; i < n; i++) {
                int t = in.nextInt();
                int d = in.nextInt();

                while (!q.isEmpty() && q.peekFirst() <= t)
                    q.pollFirst();

                int end = -1;
                if (q.size() <= b) {
                    end = (q.isEmpty() ? t : q.peekLast()) + d;
                    q.add(end);
                }

                out.print(end + " ");
            }

        }

    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(nextLine());

            return tokenizer.nextToken();
        }

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

    }
}