#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 2e5 + 10;
int main() {
  priority_queue<long long, vector<long long>, greater<long long>> pq;
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) pq.push(0);
  while (n--) {
    int s, m;
    scanf("%d%d", &s, &m);
    long long cur = max(s * 1LL, pq.top()) + m;
    pq.pop();
    printf("%lld\n", cur);
    pq.push(cur);
  }
  return 0;
}
