#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, l, m, n;
  cin >> n >> k;
  priority_queue<long long, vector<long long>, greater<long long>> pq;
  for (i = 0; i < k; i++) pq.push(0);
  long long ar[n + 10], s;
  for (i = 0; i < n; i++) {
    cin >> s >> l;
    m = pq.top();
    pq.pop();
    m = max(m, s);
    m = l + m;
    ar[i] = m;
    pq.push(m);
  }
  for (i = 0; i < n; i++) cout << ar[i] << '\n';
}
