#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10, M = 510, INF = 0x3f3f3f3f, base = 131;
priority_queue<long long, vector<long long>, greater<long long>> q;
signed main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  while (n--) {
    long long s, m;
    cin >> s >> m;
    if (q.size() >= k) {
      s = max(s, q.top()) + m;
      q.pop();
    } else
      s += m;
    cout << s << endl;
    q.push(s);
  }
  return 0;
}
