#include <bits/stdc++.h>
using namespace std;
int readint() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && c != '-')
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
inline string tos(int x) {
  string s;
  while (x) s = (char)(x % 10 + '0') + s, x /= 10;
  return s;
}
inline int pt(int a[], int l, int r) {
  int p, i, j;
  p = a[l];
  i = l;
  j = r + 1;
  for (;;) {
    while (a[++i] < p)
      if (i >= r) break;
    while (a[--j] > p)
      if (j <= l) break;
    if (i >= j)
      break;
    else
      swap(a[i], a[j]);
  }
  if (j == l) return j;
  swap(a[l], a[j]);
  return j;
}
inline void q_sort(int a[], int l, int r) {
  int q;
  if (r > l) {
    q = pt(a, l, r);
    q_sort(a, l, q - 1);
    q_sort(a, q + 1, r);
  }
}
priority_queue<long long, vector<long long>, greater<long long> > pq;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, i, sz = 0;
  long long x, y, t;
  cin.tie(0);
  cout.tie(0);
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d", &x, &y);
    if (sz < m) {
      printf("%I64d\n", x + y);
      pq.push(x + y);
      sz++;
    } else {
      t = pq.top();
      pq.pop();
      t = max(t, x);
      printf("%I64d\n", y + t);
      pq.push(y + t);
    }
  }
}
