#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int p = 0;
  int t = 0;
  while (p < n) {
    vector<pair<int, int> > x;
    while (x.size() < m && p < n) {
      int T, X;
      scanf("%d%d", &T, &X);
      x.push_back(make_pair(X, p));
      t = max(t, T);
      p++;
    }
    sort(x.begin(), x.end());
    vector<pair<int, int> > e;
    int d = 0;
    for (int i = 0; i < x.size(); i += 0) {
      int k = 1;
      while (i + k < x.size() && x[i].first == x[i + k].first) k++;
      t += x[i].first - d;
      d = x[i].first;
      for (int j = i; j < i + k; j++) e.push_back(make_pair(x[j].second, t));
      t += 1 + k / 2;
      i += k;
    }
    t += d;
    sort(e.begin(), e.end());
    for (int i = 0; i < e.size(); i++) printf("%d ", e[i].second);
  }
  return 0;
}
