#include <bits/stdc++.h>   using namespace std;   int n, b;   int t[200005], d[200005];   queue<pair<int, pair<int, int> > > Q;   long long ans[200005];   int main() {     int i, j;     scanf( %d , &n);     scanf( %d , &b);     for (i = 1; i <= n; i++) {       scanf( %d , &t[i]);       scanf( %d , &d[i]);     }     memset(ans, -1, sizeof(ans));     long long curr = 0;     i = 1;     while (1) {       if (i <= n && Q.size() == 0) {         Q.push({i, {t[i], d[i]}});         i++;       }       if (Q.size() == 0) break;       pair<int, pair<int, int> > now = Q.front();       Q.pop();       curr = max(curr, (long long)now.second.first);       long long en = curr + now.second.second;       ans[now.first] = en;       while (i <= n && Q.size() < b) {         Q.push({i, {t[i], d[i]}});         i++;       }       while (i <= n && t[i] < en) {         i++;       }       curr = en;     }     for (i = 1; i <= n; i++) printf( %lld  , ans[i]);     return 0;   }   