#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e5 + 10;
long long ans[N];
pair<int, int> a[N];
int n, m, q[N];
void prepare() {
  scanf("%d%d", &n, &m);
  for (auto i = (1); i <= (n); i++) scanf("%d%d", &a[i].first, &a[i].second);
}
void solve() {
  int top = 1, bot = 0;
  long long stime = 0;
  for (auto i = (1); i <= (n); i++) {
    while (top <= bot) {
      stime = max(stime, 1LL * a[q[top]].first);
      if (stime + a[q[top]].second <= a[i].first) {
        stime += a[q[top]].second;
        ans[q[top++]] = stime;
      } else
        break;
    }
    if (bot - top + 1 <= m) q[++bot] = i;
  }
  while (top <= bot) {
    stime = max(stime, 1LL * a[q[top]].first);
    stime += a[q[top]].second;
    ans[q[top++]] = stime;
  }
  for (auto i = (1); i <= (n); i++) printf("%lld ", ans[i] ? ans[i] : -1);
}
int main() {
  prepare();
  solve();
}
