#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  if (m > n) m = n;
  vector<long long> t(n), x(n);
  for (long long i = 0; i < n; i++) cin >> t[i] >> x[i];
  long long start = 0;
  long long curTime = 0;
  vector<long long> results(n);
  while (start < n) {
    long long end = min(n, start + m);
    long long startTime = max(curTime, t[end - 1]);
    long long pos = 0;
    vector<pair<long long, long long> > stops(end - start);
    vector<long long> nums(10001);
    for (long long i = start; i < end; i++) {
      stops[i - start] = make_pair(x[i], i);
      nums[x[i]]++;
    }
    sort(stops.begin(), stops.end());
    long long last = stops[0].first;
    curTime = startTime + last;
    for (long long i = 0; i < end - start; i++) {
      if (last == stops[i].first)
        results[stops[i].second] = curTime;
      else {
        curTime += 1 + nums[last] / 2;
        curTime += stops[i].first - last;
        last = stops[i].first;
        results[stops[i].second] = curTime;
      }
    }
    curTime += 1 + nums[last] / 2;
    curTime += last;
    start = end;
  }
  for (long long i = 0; i < n; i++) cout << results[i] << " ";
  cout << endl;
}
