#include <bits/stdc++.h>
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  std::multiset<long long> ms;
  for (long long p = 0; p < k; p++) {
    ms.insert(0);
  }
  while (n--) {
    long long t, dur;
    scanf("%lld %lld", &t, &dur);
    std::multiset<long long>::iterator it = ms.begin();
    long long s = *it;
    ms.erase(it);
    long long f = ((s > t) ? s : t) + dur;
    ms.insert(f);
    printf("%lld\n", f);
  }
  return 0;
}
