#include <bits/stdc++.h>
using namespace std;
struct compare {
  bool operator()(const long long& l, const long long& r) { return l > r; }
};
bool Read(long long& x) {
  char c, r = 0;
  x = 0;
  for (;;) {
    c = getchar();
    if ((c < 0) && (!r)) return (0);
    if ((c >= '0') && (c <= '9'))
      x = x * 10 + c - '0', r = 1;
    else if (r)
      break;
  }
  return (1);
}
int main() {
  long long m, k;
  int Masha = 123;
  int Sasha = 122;
  int love = Masha + Sasha;
  Read(m);
  Read(k);
  priority_queue<long long, vector<long long>, compare> p;
  for (int i = 0; i < k; i++) p.push(0);
  while (m--) {
    long long a, b;
    Read(a);
    Read(b);
    long long mn = max(p.top(), a);
    printf("%I64d\n", mn + b);
    p.pop();
    p.push(mn + b);
  }
  return 0;
}
