#include <bits/stdc++.h>
using namespace std;
int n, b;
pair<int, int> t[200001];
long long qu[200001], l, r;
long long ans[200001];
int main() {
  scanf("%d%d", &n, &b);
  for (int i = 1; i <= n; i++) scanf("%d%d", &t[i].first, &t[i].second);
  l = 1;
  r = 0;
  for (int i = 1; i <= n; i++) {
    while (l <= r && qu[l] <= t[i].first) l++;
    if (r - l + 1 < b + 1) {
      if (r < l) {
        ans[i] = qu[r + 1] = t[i].first + t[i].second;
      } else {
        ans[i] = qu[r + 1] = qu[r] + t[i].second;
      }
      r++;
    } else
      ans[i] = -1;
  }
  for (int i = 1; i <= n; i++) printf("%I64d\n", ans[i]);
  return 0;
}
