#include <bits/stdc++.h>
using namespace std;
int main() {
  istream& in = cin;
  long long n, b;
  in >> n >> b;
  queue<pair<long long, long long> > Queue;
  long long result[200000];
  long long t, d;
  for (int i = 0; i < n; ++i) {
    in >> t >> d;
    while (!Queue.empty()) {
      long long e = Queue.front().first;
      long long idx = Queue.front().second;
      if (e <= t) {
        Queue.pop();
        result[idx] = e;
        if (Queue.empty()) break;
        Queue.front().first += e;
      } else {
        break;
      }
    }
    if (Queue.empty()) {
      Queue.push(pair<long long, long long>(t + d, i));
    } else if (Queue.size() <= b) {
      Queue.push(pair<long long, long long>(d, i));
    } else {
      result[i] = -1;
    }
  }
  while (!Queue.empty()) {
    long long e = Queue.front().first;
    long long idx = Queue.front().second;
    Queue.pop();
    result[idx] = e;
    if (Queue.empty()) break;
    Queue.front().first += e;
  }
  for (int i = 0; i < n; ++i) cout << result[i] << " ";
  return 0;
}
