#include <bits/stdc++.h>
using namespace std;
long long n, k, s[1 << 20], m[1 << 20];
set<pair<long long, long long> >::iterator it;
set<pair<long long, long long> > S;
long long fr;
pair<long long, long long> tp;
queue<long long> qu;
long long temp;
long long ans[1 << 20];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> s[i] >> m[i];
    S.insert(make_pair(s[i], i));
  }
  fr = k;
  int itr = 1;
  while (S.size()) {
    it = S.begin();
    tp = (*it);
    S.erase(it);
    if (tp.second < 0) {
      fr++;
      if (qu.size() > 0) {
        temp = qu.front();
        qu.pop();
        ans[temp] = tp.first + m[temp];
        S.insert(make_pair(ans[temp], -itr));
        ++itr;
        --fr;
      }
    } else {
      if (fr == 0) {
        qu.push(tp.second);
        continue;
      } else {
        --fr;
        temp = tp.second;
        ans[temp] = tp.first + m[temp];
        S.insert(make_pair(ans[temp], -itr));
        ++itr;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
