#include <bits/stdc++.h>
using namespace std;
const int MAX = 501000;
const int MAXC = 15;
const int INF = 1e9;
const int MOD = 1000000007;
const double EPS = 1e-11;
struct task {
  long long end, ntask;
  bool operator<(const task other) const { return end > other.end; }
  task(long long e, long long n) : end(e), ntask(n) {}
};
int cnt;
int n, k;
priority_queue<task> ent;
long long t, ct;
long long end_time[MAX];
void lose() {
  while (!ent.empty()) {
    if (ent.top().end > t) break;
    ent.pop();
    ++cnt;
  }
}
int main() {
  cin >> n >> k;
  cnt = k;
  int in = 0;
  t = 0;
  while (in < n) {
    if (cnt == 0) {
      t = ent.top().end;
      lose();
    }
    while (cnt > 0 && in < n) {
      long long a, b;
      cin >> a >> b;
      if (a > t) t = a;
      ent.push(task(t + b, in));
      end_time[in] = t + b;
      ++in;
      --cnt;
    }
    lose();
  }
  for (int i = 0; i < n; ++i) cout << end_time[i] << '\n';
}
