#include <bits/stdc++.h>
using namespace std;
int T[100005] = {0};
int X[100005] = {0};
int main() {
  int n, m;
  scanf("%d %d ", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d %d ", &T[i], &X[i]);
  int ii = 0;
  int j = 0;
  int a_time = 0;
  int time = 0;
  while (n > 0) {
    j = min(m, n) - 1;
    a_time = max(a_time, T[ii + j]);
    map<int, pair<int, int> > mp;
    int last = -1;
    for (int k = ii; k <= ii + j; k++) {
      mp[X[k]].first++;
      last = max(last, X[k]);
    }
    int p_time = 0;
    int p_pos = 0;
    for (map<int, pair<int, int> >::iterator iter = mp.begin();
         iter != mp.end(); iter++) {
      a_time += (*iter).first - p_pos;
      (*iter).second.second = a_time;
      a_time += 1 + ((*iter).second.first / 2);
      p_pos = (*iter).first;
    }
    for (int k = ii; k <= ii + j; k++) {
      printf("%d ", mp[X[k]].second);
    }
    n -= m;
    ii = ii + j + 1;
    a_time += last;
  }
  return 0;
}
