#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  multiset<long long> items;
  long long k, n;
  cin >> k >> n;
  for (long long i = 0; i < n; i++) items.insert(0);
  vector<long long> ans;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    long long time = *items.begin();
    items.erase(items.begin());
    long long t;
    if (x > time)
      t = x + y;
    else
      t = time + y;
    ans.push_back(t);
    items.insert(t);
  }
  for (long long i = 0; i < k; i++) cout << ans[i] << endl;
  return 0;
}
