#include <bits/stdc++.h>
using namespace std;
int N, K;
priority_queue<long long> pq;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 0; i < K; i++) pq.push(0);
  for (int i = 0, s, m; i < N; i++) {
    cin >> s >> m;
    long long x = -pq.top();
    pq.pop();
    long long fin = max(x, (long long)s) + m;
    cout << fin << "\n";
    pq.push(-fin);
  }
  return 0;
}
