#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long t, d;
int n, b;
long long ans[maxn];
queue<long long> q;
int main() {
  scanf("%d%d", &n, &b);
  long long sys = 0;
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &t, &d);
    if (sys <= t) {
      if (q.empty()) {
        sys = t + d;
        ans[i] = sys;
      } else {
        while (sys <= t && !q.empty()) {
          long long x = q.front();
          q.pop();
          long long y = q.front();
          q.pop();
          long long z = q.front();
          q.pop();
          sys = max(sys + y, x + y);
          ans[z] = sys;
        }
        if (sys <= t) {
          sys = t + d;
          ans[i] = sys;
        } else {
          if (q.size() >= 3 * b) {
            ans[i] = -1;
          } else {
            q.push(t);
            q.push(d);
            q.push((long long)i);
          }
        }
      }
    } else {
      if (q.size() >= 3 * b) {
        ans[i] = -1;
      } else {
        q.push(t);
        q.push(d);
        q.push((long long)i);
      }
    }
  }
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    long long y = q.front();
    q.pop();
    long long z = q.front();
    q.pop();
    sys = max(sys + y, x + y);
    ans[z] = sys;
  }
  for (int i = 0; i < n; i++) {
    printf("%I64d ", ans[i]);
  }
  puts("");
  return 0;
}
