#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
inline long long int sqr(long long int x) { return x * x; }
long long int A[200003], B[200003], C[200003], D[200003];
long long int one, zero, ansR, numNodes;
long long int findGcd(long long int a, long long int b) {
  if (a == 0)
    return b;
  else
    return findGcd(b % a, a);
}
long long int powP(long long int a, long long int b) {
  if (b == 0) return 1 % mod;
  long long int k;
  k = powP(a, b / 2);
  k = k * k % mod;
  if (b % 2 == 0)
    return k;
  else
    return a * k % mod;
}
int main() {
  long long int T, i, j, h, l, r, k, s, b, c, a, d, q, p, n, m, w, x, y, v, z,
      t, curr, prev, sum, ans, pos, val, countA, secondMin, indicator;
  scanf("%lld%lld", &n, &b);
  long long int busy_with = 0, queue_size = 0, time_covered = 0;
  for (long long int i = (1); i <= (n); ++i) {
    scanf("%lld%lld", &A[i], &B[i]);
    while (busy_with < queue_size) {
      t = C[busy_with];
      time_covered = max(time_covered, A[t]);
      if (time_covered + B[t] <= A[i]) {
        time_covered += B[t];
        D[t] = time_covered;
        busy_with++;
      } else
        break;
    }
    w = queue_size - busy_with - 1;
    if (w < b) {
      C[queue_size] = i;
      queue_size++;
    } else
      D[i] = -1;
  }
  while (busy_with < queue_size) {
    t = C[busy_with];
    time_covered = max(time_covered, A[t]);
    time_covered += B[t];
    D[t] = time_covered;
    busy_with++;
  }
  for (long long int i = (1); i <= (n); ++i) printf("%lld ", D[i]);
  return 0;
}
