#include <bits/stdc++.h>
using namespace std;
long long myints[500 * 1000 + 1];
int N, M, i;
int s, m;
long long t;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  priority_queue<long long> rezult(myints, myints + M);
  for (i = 0; i < N; ++i) {
    cin >> s >> m;
    s = -s;
    m = -m;
    t = rezult.top();
    rezult.pop();
    t = ((t < s) ? t : s) + m;
    rezult.push(t);
    printf("%I64d\n", -t);
  }
  return 0;
}
