#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> q;
long long x;
int n, k, y;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < k; ++i) q.push(0);
  while (n--) {
    cin >> x >> y;
    x = max(x, -q.top()) + y;
    printf("%I64d\n", x);
    q.pop();
    q.push(-x);
  }
}
