#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
queue<pair<long long, int> > sq;
int main(void) {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int(i) = 0; i < (int)(N); i++) {
    int first, second;
    scanf("%d%d", &first, &second);
    q.push({first, second});
  }
  int cnt = K;
  while (!q.empty()) {
    pair<long long, int> t = q.top();
    q.pop();
    if (t.second == -1)
      if (!sq.empty()) {
        pair<long long, int> tt = sq.front();
        sq.pop();
        q.push({t.first + tt.second, -1});
        printf("%I64d\n", t.first + tt.second);
      } else
        ++cnt;
    else if (!cnt)
      sq.push(t);
    else {
      --cnt;
      q.push({t.first + t.second, -1});
      printf("%I64d\n", t.first + t.second);
    }
  }
  return 0;
}
