#include <bits/stdc++.h>
using namespace std;
int n, k, second[500500], t[500500];
set<pair<long long, int> > q;
long long ans[500500];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) scanf("%d%d", &second[i], &t[i]);
  for (int i = 0; i < min(k, n); i++) q.insert(make_pair(second[i] + t[i], i));
  for (int i = min(k, n); i < n; i++) {
    pair<long long, int> cur = *q.begin();
    q.erase(q.begin());
    ans[cur.second] = cur.first;
    q.insert(make_pair(max(cur.first, second[i] + 0ll) + t[i], i));
  }
  for (auto i : q) ans[i.second] = i.first;
  for (int i = 0; i < n; i++) printf("%I64d\n", ans[i]);
  return 0;
}
