#include <bits/stdc++.h>
using namespace std;
int n, m, t[100010], nowt, pos, ans[100010];
pair<int, int> a[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &t[i], &a[i].first);
    a[i].second = i;
  }
  for (int i = 1, j; i <= n; i = j + 1) {
    j = min(n, i + m - 1);
    sort(a + i, a + j + 1);
    nowt = max(nowt, t[j]);
    pos = 0;
    for (int k = i, l; k <= j; k = l) {
      l = k;
      while (l <= j && a[l].first == a[k].first) ++l;
      nowt += a[k].first - pos;
      for (int h = k; h < l; ++h) ans[a[h].second] = nowt;
      nowt += 1 + (l - k) / 2;
      pos = a[k].first;
    }
    nowt += pos;
  }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  return 0;
}
