#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using pi = pair<int, int>;
using vs = vector<string>;
using vpi = vector<pi>;
using ll = long long int;
template <typename T>
string tostr(T x) {
  ostringstream oss;
  oss << x;
  return oss.str();
}
template <typename T1, typename T2, typename T3>
T1 modpow(T1 a, T2 p, T3 mod) {
  T1 ret = 1;
  a %= mod;
  for (; p > 0; p /= 2) {
    if (p & 1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
  }
  return ret;
}
int dx[]{-1, 0, 1, 0, 1, 1, -1, -1};
int dy[]{0, -1, 0, 1, 1, -1, 1, -1};
constexpr auto PI = 3.14159265358979323846L;
constexpr auto oo = numeric_limits<int>::max() / 2 - 10;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr int mx = 200005;
int t[mx], d[mx];
queue<int> q;
int n, b;
ll ans[mx];
class Event {
 public:
  ll at;
  int typ, idx;
  Event(ll _at, int _typ, int _idx) {
    at = _at;
    typ = _typ;
    idx = _idx;
  }
  bool operator<(const Event& e) const {
    if (e.at == at) return typ < e.typ;
    return at > e.at;
  }
};
int main() {
  priority_queue<Event> events;
  cin >> n >> b;
  for (auto i = 0, _i = (n); i < _i; ++i) {
    cin >> t[i] >> d[i];
    events.push(Event(t[i], 0, i));
  }
  int cur = -1;
  while (!events.empty()) {
    Event e = events.top();
    events.pop();
    ;
    if (e.typ == 0) {
      if (cur == -1) {
        cur = e.idx;
        events.push(Event(e.at + d[cur], 1, cur));
      } else if ((int)(q.size()) < b) {
        q.push(e.idx);
      } else {
        ans[e.idx] = -1;
      }
    } else {
      assert(cur == e.idx);
      ans[e.idx] = e.at;
      cur = -1;
      if (!q.empty()) {
        cur = q.front();
        q.pop();
        events.push(Event(e.at + d[cur], 1, cur));
      }
    }
  }
  for (auto i = 0, _i = (n); i < _i; ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
