#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int mod = (int)1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 5 * 100100;
priority_queue<long long> q;
long long t = 0;
int main() {
  srand(time(0));
  const string file = "";
  if (!file.empty()) {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  long long n, k;
  scanf("%I64d%I64d", &n, &k);
  for (int i = 0; i < n; i++) {
    long long s, m;
    scanf("%I64d%I64d", &s, &m);
    while (q.size() == k) {
      t = -q.top();
      q.pop();
    }
    t = max(t, s);
    q.push(-t - m);
    printf("%I64d\n", t + m);
  }
  return (0);
}
