#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, x, y, ans[500005], ti;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    doing;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  cin >> x >> y;
  i = 1;
  while (!doing.empty() || i <= n) {
    if (doing.empty()) {
      ti = x;
      doing.push(make_pair(y + ti, i));
      i++;
      cin >> x >> y;
    }
    while (i <= n && doing.size() < m && x <= doing.top().first) {
      ti = x;
      doing.push(make_pair(y + ti, i));
      i++;
      cin >> x >> y;
    }
    ti = doing.top().first;
    while (!doing.empty() && doing.top().first <= ti) {
      ans[doing.top().second] = ti;
      doing.pop();
    }
    while (i <= n && doing.size() < m && x <= ti) {
      doing.push(make_pair(y + ti, i));
      i++;
      cin >> x >> y;
    }
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
