#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const double eps = 1e-6;
const double Pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MAXN = 2e5 + 5;
struct node {
  long long t, d, i;
};
node a[MAXN];
long long vi[MAXN];
int n, b;
void fun() {
  queue<node> q;
  node ne = a[1];
  vi[1] = ne.d + ne.t;
  for (int i = 2; i <= n; i++) {
    if (a[i].t >= vi[ne.i]) {
      q.push(a[i]);
      node k = q.front();
      q.pop();
      vi[k.i] = k.d + max(vi[ne.i], k.t);
      ne = k;
    } else {
      if (q.size() < b)
        q.push(a[i]);
      else
        vi[a[i].i] = -1;
    }
  }
  while (!q.empty()) {
    node k = q.front();
    q.pop();
    vi[k.i] = k.d + max(vi[ne.i], k.t);
    ne = k;
  }
}
int main() {
  scanf("%d%d", &n, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i].t, &a[i].d);
    a[i].i = i;
  }
  fun();
  for (int i = 1; i <= n; i++) printf("%lld ", vi[i]);
}
