#include <bits/stdc++.h>
using namespace std;
long long n, k;
priority_queue<long long, vector<long long>, greater<long long> > q;
signed main() {
  scanf("%lld%lld", &n, &k);
  while (n--) {
    long long s, m;
    scanf("%lld%lld", &s, &m);
    if (q.size() >= k)
      s = max(s, q.top()), q.pop();
    else
      s;
    printf("%lld\n", s + m);
    q.push(s + m);
  }
  return 0;
}
