#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6;
long long n, b, s[MAXN], m[MAXN], t = 0;
long long i, j, d = 0;
bool q[MAXN];
int main() {
  cin >> n >> b;
  fill(q, q + n, false);
  for (i = 0; i < n; i++) {
    cin >> s[i] >> m[i];
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if (i > 0) cout << endl;
    if (j == i && q[j] == false) {
      q[j] = true;
      t = s[i];
      d++;
      j++;
    }
    if (q[i] == true) {
      t += m[i];
      d--;
      cout << t;
    } else
      cout << -1;
    while (q[j] == false && t > s[j] && j < n) {
      if (d + 1 > b)
        d--;
      else
        q[j] = true;
      j++;
      d++;
    }
  }
  return 0;
}
