#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF32 = INT_MAX;
const ll INF64 = ((ll)INF32 << 29ll);
void reflex() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
}
signed main() {
  reflex();
  int n, b;
  cin >> n >> b;
  vector<pll> a(n);
  for (pll& x : a) cin >> x.first >> x.second;
  int pos = 0;
  vector<ll> ans(n);
  ll last = a.front().first;
  pair<ll, bool> inwork = {INF64, false};
  queue<ll> q;
  for (pll x : a) {
    if (x.first >= inwork.first) {
      if (!q.size())
        inwork = {0, false};
      else {
        inwork = {q.front(), true};
        q.pop();
      }
    }
    if (q.size() < b) {
      if (last < x.first) last = x.first;
      last += x.second;
      if (!q.size() && !inwork.second)
        inwork = {last, true};
      else
        q.push(last);
      ans[pos] = last;
    } else
      ans[pos] = -1;
    pos++;
  }
  for (ll x : ans) cout << x << " ";
  return false;
}
