#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010;
int n, k;
int s[maxn], m[maxn];
priority_queue<long long> server;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= k; i++) server.push(0);
  long long sta, len;
  for (int i = 1; i <= n; i++) {
    cin >> sta >> len;
    long long time = server.top();
    server.pop();
    long long rt = abs(time);
    long long st = max(sta, rt);
    long long ed = st + len;
    cout << ed << '\n';
    server.push(-ed);
  }
  return 0;
}
