#include <bits/stdc++.h>
using namespace std;
long long ans[500100], s[500100], d[500100], n, k;
multiset<long long> times, ser;
queue<int> q;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> d[i];
    times.insert(s[i]);
  }
  int i = 0;
  while (times.size()) {
    long long t = *times.begin();
    while (ser.size() && (*ser.begin()) <= t) ser.erase(ser.begin());
    while (ser.size() < k && q.size()) {
      ans[q.front()] = t + d[q.front()];
      times.insert(ans[q.front()]);
      ser.insert(ans[q.front()]);
      q.pop();
    }
    if (s[i] == t)
      if (ser.size() < k) {
        ans[i] = s[i] + d[i];
        times.insert(ans[i]);
        ser.insert(ans[i]);
        i++;
      } else {
        q.push(i);
        i++;
      }
    times.erase(times.begin());
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return -0;
}
