#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int start, last, pos;
};
queue<node> q;
long long int t[200005], d[200005], ans[200005];
int main() {
  long long int n, b, cur_time = 0;
  scanf("%I64d%I64d", &n, &b);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &t[i], &d[i]);
  }
  for (int i = 0; i < n; i++) {
    if (t[i] >= cur_time && !q.empty()) {
      node tmp = q.front();
      q.pop();
      ans[tmp.pos] = max(cur_time, tmp.start) + tmp.last;
      cur_time = ans[tmp.pos];
    }
    if (q.size() < b) {
      node tmp;
      tmp.start = t[i];
      tmp.last = d[i];
      tmp.pos = i;
      q.push(tmp);
    } else {
      ans[i] = -1;
    }
  }
  while (!q.empty()) {
    node tmp = q.front();
    q.pop();
    ans[tmp.pos] = max(cur_time, tmp.start) + tmp.last;
    cur_time = ans[tmp.pos];
  }
  int i = 0;
  for (i = 0; i < n - 1; i++) printf("%I64d ", ans[i]);
  printf("%I64d\n", ans[i]);
  return 0;
}
