#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b;
  cin >> n >> b;
  vector<pair<int, int> > queries(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &queries[i].first, &queries[i].second);
  }
  int query_index = 0;
  long long free_time = 0;
  queue<int> q;
  vector<long long> result(n, -1);
  for (int query_index = 0; query_index < n; ++query_index) {
    if (q.size() < b) {
      q.push(query_index);
    }
    while (!q.empty() && (query_index == n - 1 ||
                          free_time <= queries[query_index + 1].first)) {
      int index = q.front();
      q.pop();
      if (free_time <= queries[index].first) {
        free_time = queries[index].first + queries[index].second;
      } else {
        free_time += queries[index].second;
      }
      result[index] = free_time;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << result[i] << ' ';
  }
  printf("\n");
  return 0;
}
