#include <bits/stdc++.h>
using namespace std;
int getn() {
  int h;
  scanf("%d", &h);
  return h;
}
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& par) {
  cout << "[" << par.first << ";" << par.second << "]";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
  return out;
}
bool ccw(complex<long double> p, complex<long double> a,
         complex<long double> b) {
  if ((conj(a - p) * (b - p)).imag() <= 0)
    return (0);
  else
    return (1);
}
struct query {
  long long int t;
  long long int trva;
  int id;
  query(long long int tt, int i, long long int tr) : t(tt), id(i), trva(tr) {}
  query() {}
};
struct event {
  query q;
  bool dokoncena;
  long long int t;
  event(query qu, bool d, long long int time) : q(qu), dokoncena(d), t(time) {}
  const bool operator<(const event a) const {
    if (a.t == t) return !dokoncena;
    return a.t < t;
  }
};
int main() {
  int n = getn();
  int b = getn();
  queue<query> cakaju;
  vector<long long int> casy(n, -1);
  int t = getn();
  int d = getn();
  query robiSa(t, 0, d);
  priority_queue<event> eventy;
  eventy.push(event(robiSa, 1, t + d));
  for (int i = 0; i < n - 1; i++) {
    t = getn();
    d = getn();
    eventy.push(event(query(t, i + 1, d), 0, t));
  }
  long long int time = 0;
  while (eventy.size()) {
    event e = eventy.top();
    if (0)
      cout << "event e: query q in time " << e.q.t << " id " << e.q.id
           << " trva " << e.q.trva << " and je to konciaci event? "
           << e.dokoncena << " a v case " << e.t << endl;
    eventy.pop();
    time = e.t;
    if (e.dokoncena) {
      casy[e.q.id] = e.t;
      if (cakaju.size()) {
        robiSa = cakaju.front();
        cakaju.pop();
        eventy.push(event(robiSa, 1, time + robiSa.trva));
      } else {
        robiSa = query(-1, -1, -1);
      }
    } else {
      if (robiSa.id == -1) {
        robiSa = e.q;
        eventy.push(event(robiSa, 1, time + robiSa.trva));
      } else if (cakaju.size() < b) {
        cakaju.push(e.q);
      }
    }
  }
  cout << casy;
}
