#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(228);
const long long MAXN = 200200, M = 1000000009;
long long t[MAXN], d[MAXN], n, k, ans[MAXN], last, b;
pair<long long, long long> it;
set<pair<long long, long long>> w;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> b;
  b++;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> d[i];
    w.insert({t[i], i});
  }
  while (w.size()) {
    it = *(w.begin());
    w.erase(w.begin());
    if (it.second == -1) {
      k--;
    } else {
      if (k == b)
        ans[it.second] = -1;
      else {
        if (k == 0)
          ans[it.second] = t[it.second] + d[it.second];
        else
          ans[it.second] = last + d[it.second];
        last = ans[it.second];
        k++;
        w.insert({last, -1});
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
