#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
const int N = 1e5 + 10;
const long long INF = 1LL << 60;
long long iv[N];
long long powM(long long a, long long b) {
  long long res = 1;
  for (; b; a = a * a % 1000000007, b /= 2)
    if (b & 1) res = res * a % 1000000007;
  return res;
}
long long nckbig(int n, int k) {
  long long ans = 1;
  for (int i = 1; i <= k; ++i) {
    ans = ans * (n - i + 1) % 1000000007 * iv[i] % 1000000007;
  }
  return ans;
}
void caliv() {
  iv[1] = 1;
  for (int i = 2; i < N; i++) {
    iv[i] = 1000000007 - 1000000007 / i * iv[1000000007 % i] % 1000000007;
  }
}
long long f1[N], f2[N];
void calf() {
  f1[0] = f2[0] = 1;
  for (int i = 2; i < N; ++i) {
    f1[i] = f1[i - 1] * i % 1000000007;
    f2[i] = f2[i - i] * iv[i] % 1000000007;
  }
}
long long nck(int n, int k) {
  return f1[n] * f2[n - k] % 1000000007 * f2[k] % 1000000007;
}
long long npk(int n, int k) { return f1[n] * f2[n - k] % 1000000007; }
void Rnck(int big) {
  if (big) {
    caliv();
  } else {
    calf();
  }
}
void solve() {
  long long n, d;
  cin >> n >> d;
  queue<pair<int, pair<long long, long long>>> q;
  long long ct = 0;
  vector<long long> ans(n);
  for (long long i = 0; i < n; i++) {
    long long t, r;
    cin >> t >> r;
    if (t < ct) {
      if (q.size() < d)
        q.push(make_pair(i, make_pair(t, r)));
      else
        ans[i] = -1;
    } else {
      while (!q.empty() && ct <= t) {
        ans[q.front().first] =
            max(ct, q.front().second.first) + q.front().second.second;
        ct = max(ct, q.front().second.first) + q.front().second.second;
        q.pop();
      }
      q.push(make_pair(i, make_pair(t, r)));
    }
  }
  while (!q.empty()) {
    ans[q.front().first] =
        max(ct, q.front().second.first) + q.front().second.second;
    ct = max(ct, q.front().second.first) + q.front().second.second;
    q.pop();
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long Tests = 1;
  while (Tests--) {
    solve();
  }
  return 0;
}
