#include <bits/stdc++.h>
using namespace std;
unsigned long long int ans[500009];
set<pair<pair<unsigned long long int, unsigned long long int>,
         unsigned long long int> >
    set2;
multiset<unsigned long long int> set1;
int main() {
  unsigned long long int n, k;
  scanf("%llu%llu", &n, &k);
  for (unsigned long long int i = 0; i < n; i++) {
    unsigned long long int s, m;
    scanf("%llu%llu", &s, &m);
    set2.insert(pair<pair<unsigned long long int, unsigned long long int>,
                     unsigned long long int>(
        pair<unsigned long long int, unsigned long long int>(s, m), i));
  }
  for (unsigned long long int i = 0; i < k; i++) set1.insert(0);
  while (!set2.empty()) {
    pair<pair<unsigned long long int, unsigned long long int>,
         unsigned long long int>
        j = *(set2.begin());
    unsigned long long int a = (j.first).first, b = (j.first).second,
                           c = (j.second);
    set2.erase(set2.begin());
    unsigned long long int num = *(set1.begin());
    set1.erase(set1.begin());
    ans[c] = max(num, a) + b;
    set1.insert(max(num, a) + b);
  }
  for (unsigned long long int i = 0; i < n; i++) printf("%lld\n", ans[i]);
}
