#include <bits/stdc++.h>
using namespace std;
unsigned long long my_max(unsigned long long a, unsigned long long b) {
  return a > b ? a : b;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  int n, k;
  while (cin >> n >> k) {
    priority_queue<unsigned long long, vector<unsigned long long>,
                   greater<unsigned long long> >
        pq;
    for (int i = 0; i < k; ++i) pq.push(0);
    int s, m;
    unsigned long long ans;
    for (int i = 0; i < n; ++i) {
      cin >> s >> m;
      ans = pq.top();
      pq.pop();
      ans = my_max(ans, s) + m;
      cout << ans << endl;
      pq.push(ans);
    }
  }
  return 0;
}
