#include <bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long> > pq;
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) pq.push(0);
  long long z;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    z = max(x * 1ll, pq.top()) + y;
    pq.pop();
    pq.push(z);
    cout << z << endl;
  }
  return 0;
}
