#include <bits/stdc++.h>
using namespace std;
long long p, i, j, x, m, f, a, b, h[500005];
int n, k;
void Up(int x) {
  if (x > 1)
    if (h[x] < h[x / 2]) {
      swap(h[x], h[x / 2]);
      Up(x / 2);
    }
}
void Down(int x) {
  int r = x, st = x * 2, dr = x * 2 + 1;
  if (st <= k && h[st] < h[r]) r = st;
  if (dr <= k && h[dr] < h[r]) r = dr;
  if (r != x) {
    swap(h[r], h[x]);
    Down(r);
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (i = 1; i <= k; ++i) h[i] = 0;
  while (n--) {
    scanf("%I64d%I64d", &a, &b);
    if (h[1] < a) {
      printf("%I64d\n", a + b);
      h[1] = a + b;
      Down(1);
    } else {
      printf("%I64d\n", h[1] + b);
      h[1] += b;
      Down(1);
    }
  }
  return 0;
}
