#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, si, mi;
  scanf("%lld%lld", &n, &k);
  priority_queue<long long> myQueue;
  for (int i = 0; i < k; i++) myQueue.push(0);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &si, &mi);
    long long timePS = max(si, -myQueue.top()) + mi;
    myQueue.pop();
    myQueue.push(-timePS);
    printf("%lld\n", timePS);
  }
  return 0;
}
