#include <bits/stdc++.h>
using namespace std;
long long n, maxQSize;
queue<pair<long long, long long> > q;
vector<pair<long long, long long> > v;
vector<long long> res;
int main() {
  while (cin >> n >> maxQSize) {
    res = vector<long long>(n);
    v = vector<pair<long long, long long> >(n);
    for (int i = 0; i < n; ++i) {
      cin >> v[i].first >> v[i].second;
    }
    long long nextTime = -1;
    for (int i = 0; i < n; ++i) {
      if (v[i].first >= nextTime) {
        if (q.empty()) {
          res[i] = v[i].first + v[i].second;
          nextTime = v[i].first + v[i].second;
        } else {
          while (!q.empty() && v[i].first >= nextTime) {
            res[q.front().first] = nextTime + q.front().second;
            nextTime += q.front().second;
            q.pop();
          }
          i--;
        }
      } else {
        if (q.size() < maxQSize)
          q.push(make_pair(i, v[i].second));
        else
          res[i] = -1;
      }
    }
    while (!q.empty()) {
      res[q.front().first] = nextTime + q.front().second;
      nextTime += q.front().second;
      q.pop();
    }
    for (int i = 0; i < n; ++i) {
      if (i) cout << " ";
      cout << res[i];
    }
    cout << '\n';
  }
  return 0;
}
