#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long>> Set;
long long n, q;
pair<long long, long long> qr[222222];
long long res[222222];
queue<long long> qq;
long long ht = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(res, -1, sizeof(res));
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> qr[i].first >> qr[i].second;
    Set.insert({qr[i].first, i});
  }
  for (auto i : Set) {
    if (i.second > 0) {
      if (ht) {
        if (qq.size() < q) {
          qq.push(i.second);
        } else {
        }
      } else {
        ht = i.second;
        long long time = i.first + qr[i.second].second;
        Set.insert({time, -ht});
        res[i.second] = time;
      }
    } else {
      long long is = -i.second;
      if (qq.size()) {
        ht = qq.front();
        qq.pop();
        long long time = i.first + qr[ht].second;
        Set.insert({time, -ht});
        res[ht] = time;
      } else {
        ht = 0;
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << res[i] << " ";
}
