#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, B;
  cin >> N >> B;
  vector<long long> res(N, -1);
  queue<pair<long long, long long> > Q;
  long long endTime = -1;
  for (long long i = 0; i < N; i++) {
    long long t, d;
    cin >> t >> d;
    while (endTime <= t) {
      if (Q.size()) {
        res[Q.front().second] = endTime = endTime + Q.front().first;
        Q.pop();
      } else {
        endTime = t;
        break;
      }
    }
    if (Q.size() < B) {
      Q.push({d, i});
    }
  }
  while (Q.size()) {
    res[Q.front().second] = endTime = endTime + Q.front().first;
    Q.pop();
  }
  for (long long i = 0; i < N; i++) cout << res[i] << " ";
  cout << endl;
}
