#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> x, t, ans;
int main() {
  cin >> n >> m;
  x.resize(n);
  t.resize(n);
  ans.resize(n);
  for (int i = 0; i < n; ++i) cin >> t[i] >> x[i];
  int curt = 0;
  for (int i = 0; i < n / m + (n % m != 0); ++i) {
    int st = i * m, en = min((i + 1) * m, n);
    curt = max(curt, t[en - 1]);
    map<int, vector<int> > cnt;
    int prevx = 0;
    for (int j = st; j < en; ++j) cnt[x[j]].push_back(j);
    for (map<int, vector<int> >::const_iterator it = cnt.begin();
         it != cnt.end(); ++it) {
      curt += it->first - prevx;
      for (vector<int>::const_iterator idit = it->second.begin();
           idit != it->second.end(); ++idit)
        ans[*idit] = curt;
      curt += 1 + it->second.size() / 2;
      prevx = it->first;
    }
    curt += prevx;
  }
  for (int i = 0; i < n; ++i) cout << ans[i] << " ";
  return 0;
}
