#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  greater<long long> gi;
  vector<long long> q(k);
  for (int i = 0; i < n; ++i) {
    int s, m;
    cin >> s >> m;
    long long tn = max((long long)s, q.front()) + m;
    pop_heap(begin(q), end(q), gi);
    q.back() = tn;
    push_heap(begin(q), end(q), gi);
    cout << tn << "\n";
  }
}
