#include <bits/stdc++.h>
using namespace std;
set<pair<pair<int, int>, int> > s;
pair<pair<int, int>, int> a[100005];
int ans[100005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].second = i;
  }
  sort(a, a + n);
  int t = 0;
  for (int i = 0; i < n; i++) {
    int st;
    for (int j = i; j < min(n, i + m); j++) {
      s.insert(make_pair(make_pair(a[j].first.second, a[j].first.first),
                         a[j].second));
      st = a[j].first.first;
    }
    t = max(t, st);
    while (s.size()) {
      pair<pair<int, int>, int> p = *s.begin();
      s.erase(p);
      t += p.first.first;
      ans[p.second] = t;
      int x = 1;
      while (p.first.first == (*s.begin()).first.first) {
        ans[s.begin()->second] = t;
        s.erase(s.begin());
        x++;
      }
      t += 1 + x / 2;
      t -= p.first.first;
      if (s.size() == 0) t += 2 * p.first.first;
    }
    i += m - 1;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
