#include <bits/stdc++.h>
using namespace std;
int a[5555555], b[5555555];
long long answer[5555555];
priority_queue<long long> my;
int main() {
  int n, k;
  scanf("%d %d\n", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d\n", &a[i], &b[i]);
  }
  memset(answer, 0, sizeof(answer));
  for (int i = 1; i <= k; ++i) {
    my.push(0);
  }
  for (int i = 1; i <= n; ++i) {
    long long currentTime = -my.top();
    my.pop();
    if (currentTime < a[i]) {
      currentTime = a[i];
    }
    answer[i] = currentTime + (long long)b[i];
    my.push(-answer[i]);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%I64d\n", answer[i]);
  }
  return 0;
}
