#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int, vector<long long int>, greater<long long int> > q;
long long int tmp, a, b, n, k;
int main() {
  scanf("%I64d%I64d", &n, &k);
  for (int i = 0; i < k; i++) q.push(0);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &a, &b);
    tmp = q.top();
    q.pop();
    tmp = max(tmp, a);
    printf("%I64d\n", tmp + b);
    tmp += b;
    q.push(tmp);
  }
  return 0;
}
