#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<long long> pq;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    pq.push(0);
  }
  for (int i = 1; i <= n; i++) {
    long long g = pq.top(), x, y;
    pq.pop();
    g = fabs(g);
    scanf("%lld %lld", &x, &y);
    if (g > x) {
      cout << g + y << endl;
      pq.push(-(g + y));
    } else {
      cout << x + y << endl;
      pq.push(-(x + y));
    }
    cout << endl;
  }
  return 0;
}
