#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> q;
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) q.push(0);
  for (int i = 1; i <= n; i++) {
    long long s, m;
    cin >> s >> m;
    s = max(s, -q.top()) + m;
    q.pop();
    cout << s << endl;
    q.push(-s);
  }
  return 0;
}
