#include <bits/stdc++.h>
using namespace std;
long long n, m, t, x, ans[100100], mx = -1, curtime;
vector<pair<long long, long long> > v;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    v.push_back({x, i});
    mx = max(mx, t);
    if (v.size() == m) {
      if (mx > curtime) curtime += mx - curtime;
      long long last = 0;
      sort(v.begin(), v.end());
      for (int I = 0; I < v.size(); I++) {
        curtime += v[I].first - last;
        last = v[I].first;
        long long k = 1;
        ans[v[I].second] = curtime;
        for (int j = I + 1; j < v.size(); j++) {
          if (v[I].first != v[j].first) {
            break;
          }
          I = j;
          k++;
          ans[v[j].second] = curtime;
        }
        curtime += 1 + (k / 2);
      }
      mx = -1;
      if (i != n - 1) {
        curtime += v[v.size() - 1].first;
      }
      v.clear();
    }
  }
  if (mx != -1) {
    if (mx > curtime) curtime += mx - curtime;
    sort(v.begin(), v.end());
    long long last = 0;
    for (int I = 0; I < v.size(); I++) {
      curtime += v[I].first - last;
      last = v[I].first;
      long long k = 1;
      ans[v[I].second] = curtime;
      for (int j = I + 1; j < v.size(); j++) {
        if (v[I].first != v[j].first) {
          break;
        }
        I = j;
        k++;
        ans[v[j].second] = curtime;
      }
      curtime += 1 + (k / 2);
    }
  }
  cout << ans[0];
  for (int i = 1; i < n; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}
