#include <bits/stdc++.h>
using namespace std;
struct node {
  int t, d, idx;
};
int main() {
  int n, b;
  scanf("%d%d", &n, &b);
  node arr[n];
  for (int i = 0; i < n; ++i) {
    int t, d;
    scanf("%d%d", &t, &d);
    arr[i] = {t, d, i};
  }
  queue<node> q;
  long long res[n];
  long long en = arr[0].t + arr[0].d;
  res[0] = en;
  int i = 1;
  while (i < n) {
    if (en > arr[i].t) {
      if ((int)q.size() < b)
        q.push(arr[i]);
      else
        res[i] = -1;
      ++i;
    } else {
      if (!q.empty()) {
        node temp = q.front();
        q.pop();
        en += temp.d;
        res[temp.idx] = en;
      } else {
        en = arr[i].t + arr[i].d;
        res[i] = en;
        ++i;
      }
    }
  }
  while (!q.empty()) {
    node temp = q.front();
    q.pop();
    en += temp.d;
    res[temp.idx] = en;
  }
  for (int i = 0; i < n; ++i) printf("%I64d ", res[i]);
  return 0;
}
