#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000001000;
const int mod = 1000 * 1000 * 1000 + 7;
const int mod9 = 1000 * 1000 * 1000 + 9;
const double PI = 3.1415926535897932;
double sqr(double first) { return first * first; };
long double sqr(long double first) { return first * first; };
long long sqr(long long first) { return first * first; };
long long sqr(int first) { return first * 1LL * first; };
long long gcd(long long a, long long b) {
  while (b) a %= b, swap(a, b);
  return a;
}
long long bpm(long long a, long long n = -2, long long m = mod) {
  n = n >= 0 ? n : m + n;
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % m;
    a = (a * a) % m;
    n >>= 1;
  }
  return r;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
  return sqr(x1 - x2) + sqr(y1 - y2);
}
std::ostream& operator<<(std::ostream& os, pair<int, int> p) {
  return os << "{" << p.first << " " << p.second << "}";
}
const int N = 200005;
long long d[N];
int main() {
  set<pair<long long, long long> > st;
  int count = 0;
  long long time = 0;
  int n, b;
  scanf("%d %d", &n, &b);
  ;
  b++;
  for (int i = 1; i <= n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    ;
    st.insert({first, i});
    d[i] = second;
  }
  while (st.size()) {
    auto p = *st.begin();
    if (p.second < 0) {
      count--;
      d[-p.second] = p.first;
    } else {
      if (count < b) {
        count++;
        st.insert({(time = max(time, p.first) + d[p.second]), -p.second});
      } else {
        d[p.second] = -1;
      }
    }
    st.erase(p);
  }
  for (int i = 1; i <= n; i++) {
    cout << d[i] << " ";
  }
  cout << "\n";
  return 0;
}

### Prompt

Your task is to create a Cpp solution to the following problem:

In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment ti and needs to be processed for di units of time. All ti are guaranteed to be distinct.

When a query appears server may react in three possible ways: 

  1. If server is free and query queue is empty, then server immediately starts to process this query. 
  2. If server is busy and there are less than b queries in the queue, then new query is added to the end of the queue. 
  3. If server is busy and there are already b queries pending in the queue, then new query is just rejected and will never be processed. 



As soon as server finished to process some query, it picks new one from the queue (if it's not empty, of course). If a new query comes at some moment x, and the server finishes to process another query at exactly the same moment, we consider that first query is picked from the queue and only then new query appears.

For each query find the moment when the server will finish to process it or print -1 if this query will be rejected.

Input

The first line of the input contains two integers n and b (1 ≤ n, b ≤ 200 000) — the number of queries and the maximum possible size of the query queue.

Then follow n lines with queries descriptions (in chronological order). Each description consists of two integers ti and di (1 ≤ ti, di ≤ 109), where ti is the moment of time when the i-th query appears and di is the time server needs to process it. It is guaranteed that ti - 1 < ti for all i > 1.

Output

Print the sequence of n integers e1, e2, ..., en, where ei is the moment the server will finish to process the i-th query (queries are numbered in the order they appear in the input) or  - 1 if the corresponding query will be rejected.

Examples

Input

5 1
2 9
4 8
10 9
15 2
19 1


Output

11 19 -1 21 22 


Input

4 1
2 8
4 8
10 9
15 2


Output

10 18 27 -1 

Note

Consider the first sample. 

  1. The server will start to process first query at the moment 2 and will finish to process it at the moment 11. 
  2. At the moment 4 second query appears and proceeds to the queue. 
  3. At the moment 10 third query appears. However, the server is still busy with query 1, b = 1 and there is already query 2 pending in the queue, so third query is just rejected. 
  4. At the moment 11 server will finish to process first query and will take the second query from the queue. 
  5. At the moment 15 fourth query appears. As the server is currently busy it proceeds to the queue. 
  6. At the moment 19 two events occur simultaneously: server finishes to proceed the second query and the fifth query appears. As was said in the statement above, first server will finish to process the second query, then it will pick the fourth query from the queue and only then will the fifth query appear. As the queue is empty fifth query is proceed there. 
  7. Server finishes to process query number 4 at the moment 21. Query number 5 is picked from the queue. 
  8. Server finishes to process query number 5 at the moment 22. 

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000001000;
const int mod = 1000 * 1000 * 1000 + 7;
const int mod9 = 1000 * 1000 * 1000 + 9;
const double PI = 3.1415926535897932;
double sqr(double first) { return first * first; };
long double sqr(long double first) { return first * first; };
long long sqr(long long first) { return first * first; };
long long sqr(int first) { return first * 1LL * first; };
long long gcd(long long a, long long b) {
  while (b) a %= b, swap(a, b);
  return a;
}
long long bpm(long long a, long long n = -2, long long m = mod) {
  n = n >= 0 ? n : m + n;
  long long r = 1;
  while (n) {
    if (n & 1) r = (r * a) % m;
    a = (a * a) % m;
    n >>= 1;
  }
  return r;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
  return sqr(x1 - x2) + sqr(y1 - y2);
}
std::ostream& operator<<(std::ostream& os, pair<int, int> p) {
  return os << "{" << p.first << " " << p.second << "}";
}
const int N = 200005;
long long d[N];
int main() {
  set<pair<long long, long long> > st;
  int count = 0;
  long long time = 0;
  int n, b;
  scanf("%d %d", &n, &b);
  ;
  b++;
  for (int i = 1; i <= n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    ;
    st.insert({first, i});
    d[i] = second;
  }
  while (st.size()) {
    auto p = *st.begin();
    if (p.second < 0) {
      count--;
      d[-p.second] = p.first;
    } else {
      if (count < b) {
        count++;
        st.insert({(time = max(time, p.first) + d[p.second]), -p.second});
      } else {
        d[p.second] = -1;
      }
    }
    st.erase(p);
  }
  for (int i = 1; i <= n; i++) {
    cout << d[i] << " ";
  }
  cout << "\n";
  return 0;
}

```