#include <bits/stdc++.h>
using namespace std;
long long n, b, res[200000 + 2], valid[200000 + 2];
struct ab {
  long long srt, dr, id;
} arr[200000 + 2];
bool cmp(ab l, ab r) { return l.srt < r.srt; }
int main() {
  scanf("%I64d %I64d", &n, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d %I64d", &arr[i].srt, &arr[i].dr);
    arr[i].id = i;
  }
  sort(arr + 1, arr + n + 1, cmp);
  long long server = 0;
  queue<ab> q;
  for (int i = 1; i <= n; i++) {
    if (arr[i].srt >= server) {
      if (q.empty()) {
        server = arr[i].srt + arr[i].dr;
        res[arr[i].id] = server;
      } else {
        ab tmp = q.front();
        q.pop();
        if (tmp.srt >= server)
          server = tmp.srt + tmp.dr;
        else
          server += tmp.dr;
        res[tmp.id] = server;
        q.push(arr[i]);
      }
    } else {
      if (q.size() < b) {
        q.push(arr[i]);
      } else {
        res[arr[i].id] = -1;
      }
    }
  }
  while (!q.empty()) {
    ab tmp = q.front();
    q.pop();
    if (tmp.srt >= server)
      server = tmp.srt + tmp.dr;
    else
      server += tmp.dr;
    res[tmp.id] = server;
  }
  for (int i = 1; i <= n; i++) printf("%I64d ", res[i]);
  return 0;
}
