#include <bits/stdc++.h>
using namespace std;
long double eps = 1e-9;
const long long INF = 1e18;
const long long mod = 1e9 + 9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, len;
  cin >> n >> len;
  long long s, t;
  queue<pair<long long, long long> > q;
  vector<long long> res(n);
  long long ft = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s >> t;
    bool flag = true;
    while (flag) {
      if (ft > s) {
        flag = false;
        continue;
      }
      if (q.empty()) {
        flag = false;
        continue;
      } else {
        pair<long long, long long> elem = q.front();
        ft += elem.second;
        res[elem.first] = ft;
        q.pop();
      }
    }
    if (s < ft) {
      if (q.size() < len) {
        q.push(make_pair(i, t));
      } else {
        res[i] = -1;
      }
    } else {
      ft = s + t;
      res[i] = ft;
    }
  }
  while (!q.empty()) {
    pair<long long, long long> elem = q.front();
    ft += elem.second;
    res[elem.first] = ft;
    q.pop();
  }
  for (long long x : res) {
    cout << x << ' ';
  }
  return 0;
}
