#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long SZ = 2000010;
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-6;
const long long MUL = 239017;
list<pair<long long, pair<long long, long long>>> q;
long long ans[SZ];
int main() {
  srand(330699524);
  ios::sync_with_stdio(false);
  cout.precision(20);
  long long n, b;
  cin >> n >> b;
  long long activebefore = -INF;
  for (long long i = 0; i < n; i++) {
    long long t, l;
    cin >> t >> l;
    while (q.size() &&
           max(activebefore, q.front().second.first) + q.front().first <= t) {
      ans[q.front().second.second] = activebefore =
          max(activebefore, q.front().second.first) + q.front().first;
      q.pop_front();
    }
    if (q.size() && activebefore <= t) {
      ans[q.front().second.second] = activebefore =
          max(activebefore, q.front().second.first) + q.front().first;
      q.pop_front();
    }
    if (q.size() < b)
      q.push_back({l, {t, i}});
    else
      ans[i] = -1;
  }
  while (q.size()) {
    ans[q.front().second.second] = activebefore =
        max(activebefore, q.front().second.first) + q.front().first;
    q.pop_front();
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << "\n";
  return 0;
}
