#include <bits/stdc++.h>
using namespace std;
const int max_n = 555555, inf = 1111111111;
int n, k, t, d;
multiset<long long> q;
int main() {
  scanf("%d%d", &n, &k);
  while (k--) q.insert(0);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &t, &d);
    {
      long long t1 = *q.begin();
      q.erase(q.find(t1));
      if (t1 < t) t1 = t;
      printf("%I64d\n", t1 + d);
      q.insert(t1 + d);
    }
  }
  return 0;
}
