#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
struct Query {
  int t, d, id;
};
int main() {
  int n, b, t, d;
  scanf("%d %d", &n, &b);
  queue<Query> q;
  long long curTime = 0;
  vector<long long> res(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &t, &d);
    while (q.size() && curTime <= t) {
      auto query = q.front();
      q.pop();
      curTime += query.d;
      res[query.id] = curTime;
    }
    if (q.empty() && curTime <= t) {
      curTime = t + d;
      res[i] = curTime;
    } else if (q.size() < b) {
      q.push({t, d, i});
    } else {
      res[i] = -1;
    }
  }
  while (q.size()) {
    auto query = q.front();
    q.pop();
    curTime += query.d;
    res[query.id] = curTime;
  }
  for (auto &p : res) printf("%I64d ", p);
}
