#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, d;
  long long t, T = 0;
  cin >> n >> b;
  deque<pair<long long, int> > D;
  long long I[n];
  for (int i = 0; i < n; i++) {
    cin >> t >> d;
    while (D.size() > 0 && D.back().first + T <= t) {
      T += D.back().first;
      I[D.back().second] = T;
      D.pop_back();
    }
    if (D.size() == 0) {
      T = t;
    }
    if (D.size() >= b + 1) {
      I[i] = -1;
    } else {
      D.push_front({d, i});
    }
  }
  t = 100000000000000000;
  while (D.size() > 0 && D.back().first + T <= t) {
    T += D.back().first;
    I[D.back().second] = T;
    D.pop_back();
  }
  for (int i = 0; i < n; i++) {
    cout << I[i] << " ";
  }
  return 0;
}
