#include <bits/stdc++.h>
using namespace std;
map<long long int, int> a;
int main() {
#pragma warning(disable : 4996)
  int n, m;
  long long int t, dl;
  scanf("%d%d", &n, &m);
  a[0] = 1;
  int used = 1;
  long long int k;
  long long int s;
  for (int i = 1; i <= n; i++) {
    scanf("%I64d%I64d", &t, &dl);
    if (used < m) {
      k = t + dl;
      cout << k << endl;
      used++;
      a[t + dl]++;
    } else {
      auto it = a.begin();
      s = it->first;
      a[it->first]--;
      if (a[it->first] == 0) {
        a.erase(it->first);
      }
      s = max(s, t);
      a[s + dl]++;
      k = dl + s;
      cout << k << endl;
    }
  }
  return 0;
}
