#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
pair<long long, int> seg[4 * (int)(5e5 + 25)];
void build(int i, int l, int r) {
  if (l == r) {
    seg[i].first = 0;
    seg[i].second = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(2 * i, l, mid);
  build(2 * i + 1, mid + 1, r);
  if (seg[2 * i].first <= seg[2 * i + 1].first) {
    seg[i] = seg[2 * i];
  } else {
    seg[i] = seg[2 * i + 1];
  }
}
void update(int i, int l, int r, int x, long long val) {
  if (x < l || x > r) {
    return;
  }
  if (l == r && l == x) {
    seg[i].first = val;
    return;
  }
  int mid = (l + r) >> 1;
  update(2 * i, l, mid, x, val);
  update(2 * i + 1, mid + 1, r, x, val);
  if (seg[2 * i].first <= seg[2 * i + 1].first) {
    seg[i] = seg[2 * i];
  } else {
    seg[i] = seg[2 * i + 1];
  }
}
void solve() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  build(1, 1, k);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    long long val = seg[1].first;
    int idx = seg[1].second;
    long long ans = max(val, (long long)x) + y;
    printf("%lld", ans);
    printf("\n");
    update(1, 1, k, idx, ans);
  }
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
